home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_povray.idb / usr / freeware / lib / povray31 / povuser.txt.z / povuser.txt
Encoding:
Text File  |  1999-04-16  |  840.7 KB  |  20,676 lines

  1.                                 
  2.                Persistence of Vision (tm) Ray-Tracer
  3.                                 
  4.                       POV-Ray (tm) Version 3.1
  5.                                 
  6.                       User's Documentation
  7.                          September 1998
  8.                                 
  9.                     Copyright 1998 POV-Team (tm)
  10.                                 
  11. POV-Ray (tm) is based on DKBTrace 2.12 by David K. Buck and Aaron A.
  12.                             Collins.
  13.                                 
  14.    POV-Ray, POV-Help, POV-Team, and Persistence of Vision are
  15.                    trademarks of the POV-Team.
  16.                                 
  17. 1    Introduction
  18.  1.1  Program Description
  19.  1.2What is Ray-Tracing?
  20.  1.3What is POV-Ray?
  21.  1.4How Do I Begin?
  22.  1.5Notation and Basic Assumptions
  23.  1.6What's New in POV-Ray 3.1?
  24.   1.6.1Media Replaces Halo & Atmosphere
  25.   1.6.2New #macro Feature
  26.   1.6.3Arrays Added
  27.   1.6.4File I/O and other Directives
  28.   1.6.5Additional New Features
  29. 2 Beginning Tutorial
  30.  2.1Our First Image
  31.   2.1.1Understanding POV-Ray's Coordinate System
  32.   2.1.2Adding Standard Include Files
  33.   2.1.3Adding a Camera
  34.   2.1.4Describing an Object
  35.   2.1.5Adding Texture to an Object
  36.   2.1.6Defining a Light Source
  37.  2.2Simple Shapes
  38.   2.2.1Box Object
  39.   2.2.2Cone Object
  40.   2.2.3Cylinder Object
  41.   2.2.4Plane Object
  42.  2.3CSG Objects
  43.   2.3.1What is CSG?
  44.   2.3.2CSG Union
  45.   2.3.3CSG Intersection
  46.   2.3.4CSG Difference
  47.   2.3.5CSG Merge
  48.   2.3.6CSG Pitfalls
  49.     2.3.6.1   Coincidence Surfaces
  50.  2.4Advanced Shapes
  51.   2.4.1Bicubic Patch Object
  52.   2.4.2Blob Object
  53.     2.4.2.1   Component Types and Other New Features
  54.     2.4.2.2   Complex Blob Constructs and Negative Strength
  55.   2.4.3Height Field Object
  56.   2.4.4Lathe Object
  57.     2.4.4.1   Understanding The Concept of Splines
  58.   2.4.5Mesh Object
  59.   2.4.6Polygon Object
  60.   2.4.7Prism Object
  61.     2.4.7.1   Teaching An Old Spline New Tricks
  62.     2.4.7.2   Smooth Transitions
  63.     2.4.7.3   Multiple Sub-Shapes
  64.     2.4.7.4   Conic Sweeps And The Tapering Effect
  65.   2.4.8Superquadric Ellipsoid Object
  66.   2.4.9Surface of Revolution Object
  67.   2.4.10                                            Text Object
  68.   2.4.11                                           Torus Object
  69.  2.5The Light Source
  70.   2.5.1The Pointlight Source
  71.   2.5.2The Spotlight Source
  72.   2.5.3The Cylindrical Light Source
  73.   2.5.4The Area Light Source
  74.   2.5.5The Ambient Light Source
  75.   2.5.6Light Source Specials
  76.     2.5.6.1   Using Shadowless Lights
  77.     2.5.6.2   Assigning an Object to a Light Source
  78.     2.5.6.3   Using Light Fading
  79.  2.6Simple Texture Options
  80.   2.6.1Surface Finishes
  81.   2.6.2Adding Bumpiness
  82.   2.6.3Creating Color Patterns
  83.   2.6.4Pre-defined Textures
  84.  2.7Advanced Texture Options
  85.   2.7.1Pigments
  86.     2.7.1.1   Using Color List Pigments
  87.     2.7.1.2   Using Pigment and Patterns
  88.     2.7.1.3   Using Pattern Modifiers
  89.     2.7.1.4   Using Transparent Pigments and Layered Textures
  90.     2.7.1.5   Using Pigment Maps
  91.   2.7.2Normals
  92.     2.7.2.1   Using Basic Normal Modifiers
  93.     2.7.2.2   Blending Normals
  94.   2.7.3Finishes
  95.     2.7.3.1   Using Ambient
  96.     2.7.3.2   Using Surface Highlights
  97.     2.7.3.3   Using Reflection and Metallic
  98.     2.7.3.4   Using Iridescence
  99.   2.7.4Working With Pigment Maps
  100.   2.7.5Working With Normal Maps
  101.   2.7.6Working With Texture Maps
  102.   2.7.7Working With List Textures
  103.   2.7.8What About Tiles?
  104.   2.7.9Average Function
  105.   2.7.10                          Working With Layered Textures
  106.     2.7.10.1  Declaring Layered Textures
  107.     2.7.10.2  Another Layered Textures Example
  108.   2.7.11                     When All Else Fails: Material Maps
  109.   2.7.12                        Limitations Of Special Textures
  110.  2.8Using the Camera
  111.   2.8.1Using Focal Blur
  112.  2.9Using Atmospheric Effects
  113.   2.9.1The Background
  114.   2.9.2The Sky Sphere
  115.     2.9.2.1   Creating a Sky with a Color Gradient
  116.     2.9.2.2   Adding the Sun
  117.     2.9.2.3   Adding Some Clouds
  118.   2.9.3The Fog
  119.     2.9.3.1   A Constant Fog
  120.     2.9.3.2   Setting a Minimum Translucency
  121.     2.9.3.3   Creating a Filtering Fog
  122.     2.9.3.4   Adding Some Turbulence to the Fog
  123.     2.9.3.5   Using Ground Fog
  124.     2.9.3.6   Using Multiple Layers of Fog
  125.     2.9.3.7   Fog and Hollow Objects
  126.   2.9.4The Rainbow
  127.     2.9.4.1   Starting With a Simple Rainbow
  128.     2.9.4.2   Increasing the Rainbow's Translucency
  129.     2.9.4.3   Using a Rainbow Arc
  130.   2.9.5Animation
  131.     2.9.5.1   The Clock Variable: Key To It All
  132.     2.9.5.2   Clock Dependant Variables And Multi-Stage
  133.     Animations
  134.     2.9.5.3   The Phase Keyword
  135.     2.9.5.4   Do Not Use Jitter Or Crand
  136.     2.9.5.5   INI File Settings
  137. 3 POV-Ray Options
  138.  3.1Setting POV-Ray Options
  139.   3.1.1Command Line Switches
  140.   3.1.2Using INI Files
  141.   3.1.3Using the POVINI Environment Variable
  142.  3.2Options Reference
  143.   3.2.1Animation Options
  144.     3.2.1.1   External Animation Loop
  145.     3.2.1.2   Internal Animation Loop
  146.     3.2.1.3   Subsets of Animation Frames
  147.     3.2.1.4   Cyclic Animation
  148.     3.2.1.5   Field Rendering
  149.   3.2.2Output Options
  150.     3.2.2.1   General Output Options
  151.      3.2.2.1.1                       Height and Width of Output
  152.      3.2.2.1.2                           Partial Output Options
  153.      3.2.2.1.3                             Interrupting Options
  154.      3.2.2.1.4                                 Resuming Options
  155.     3.2.2.2   Display Output Options
  156.      3.2.2.2.1                        Display Hardware Settings
  157.      3.2.2.2.2                         Display Related Settings
  158.      3.2.2.2.3                                   Mosaic Preview
  159.     3.2.2.3   File Output Options
  160.      3.2.2.3.1                                 Output File Type
  161.      3.2.2.3.2                                 Output File Name
  162.      3.2.2.3.3                               Output File Buffer
  163.     3.2.2.4   CPU Utilization Histogram
  164.      3.2.2.4.1                                        File Type
  165.      3.2.2.4.2                                        File Name
  166.      3.2.2.4.3                                        Grid Size
  167.   3.2.3Scene Parsing Options
  168.     3.2.3.1   Input File Name
  169.     3.2.3.2   Library Paths
  170.     3.2.3.3   Language Version
  171.   3.2.4Shell-out to Operating System
  172.     3.2.4.1   String Substitution in Shell Commands
  173.     3.2.4.2   Shell Command Sequencing
  174.     3.2.4.3   Shell Command Return Actions
  175.   3.2.5Text Output
  176.     3.2.5.1   Text Streams
  177.     3.2.5.2   Console Text Output
  178.     3.2.5.3   Directing Text Streams to Files
  179.     3.2.5.4   Help Screen Switches
  180.   3.2.6Tracing Options
  181.     3.2.6.1   Quality Settings
  182.     3.2.6.2   Radiosity Setting
  183.     3.2.6.3   Automatic Bounding Control
  184.     3.2.6.4   Removing User Bounding
  185.     3.2.6.5   Anti-Aliasing Options
  186. 4 Scene Description Language
  187.  4.1Language Basics
  188.   4.1.1Identifiers and Keywords
  189.   4.1.2Comments
  190.   4.1.3Float Expressions
  191.     4.1.3.1   Float Literals
  192.     4.1.3.2   Float Identifiers
  193.     4.1.3.3   Float Operators
  194.     4.1.3.4   Built-in Float Identifiers
  195.     4.1.3.5   Boolean Keywords
  196.     4.1.3.6   Float Functions
  197.   4.1.4Vector Expressions
  198.     4.1.4.1   Vector Literals
  199.     4.1.4.2   Vector Identifiers
  200.     4.1.4.3   Vector Operators
  201.     4.1.4.4   Operator Promotion
  202.     4.1.4.5   Built-in Vector Identifiers
  203.     4.1.4.6   Vector Functions
  204.   4.1.5Specifying Colors
  205.     4.1.5.1   Color Vectors
  206.     4.1.5.2   Color Keywords
  207.     4.1.5.3   Color Identifiers
  208.     4.1.5.4   Color Operators
  209.     4.1.5.5   Common Color Pitfalls
  210.   4.1.6Strings
  211.     4.1.6.1   String Literals
  212.     4.1.6.2   String Identifiers
  213.     4.1.6.3   String Functions
  214.   4.1.7Array Identifiers
  215.     4.1.7.1   Declaring Arrays
  216.     4.1.7.2   Array Initalizers
  217.  4.2Language Directives
  218.   4.2.1Include Files and the #include Directive.
  219.   4.2.2The #declare and #local Directives
  220.     4.2.2.1   Declaring identifiers
  221.     4.2.2.2   #declare vs. #local
  222.     4.2.2.3   Identifier Name Collisions
  223.     4.2.2.4   Destroying Identifiers with #undef
  224.   4.2.3File I/O Directives
  225.     4.2.3.1   The #fopen Directive
  226.     4.2.3.2   The #fclose Directive
  227.     4.2.3.3   The #read Directive
  228.     4.2.3.4   The #write Directive
  229.   4.2.4The #default Directive
  230.   4.2.5The #version Directive
  231.   4.2.6Conditional Directives
  232.     4.2.6.1   The #if...#else...#end Directives
  233.     4.2.6.2   The #ifdef and #ifndef Directives
  234.     4.2.6.3   The #switch, #case, #range and #break Directives
  235.     4.2.6.4   The #while...#end Directive
  236.   4.2.7User Message Directives
  237.     4.2.7.1   Text Message Streams
  238.     4.2.7.2   Text Formatting
  239.   4.2.8User Defined Macros
  240.     4.2.8.1   The #macro Directive
  241.     4.2.8.2   Invoking Macros
  242.     4.2.8.3   Are POV-Ray Macros a Function or a Macro?
  243.     4.2.8.4   Returning a Value Like a Function
  244.     4.2.8.5   Returning Values Via Parameters
  245.  4.3POV-Ray Coordinate System
  246.   4.3.1Transformations
  247.     4.3.1.1   Translate
  248.     4.3.1.2   Scale
  249.     4.3.1.3   Rotate
  250.     4.3.1.4   Matrix Keyword
  251.   4.3.2Transformation Order
  252.   4.3.3Transform Identifiers
  253.   4.3.4Transforming Textures and Objects
  254.  4.4Camera
  255.   4.4.1Placing the Camera
  256.     4.4.1.1   Location and Look_At
  257.     4.4.1.2   The Sky Vector
  258.     4.4.1.3   Angle
  259.     4.4.1.4   The Direction Vector
  260.     4.4.1.5   Up and Right Vectors
  261.      4.4.1.5.1                                     Aspect Ratio
  262.      4.4.1.5.2 Handedness
  263.     4.4.1.6   Transforming the Camera
  264.   4.4.2Types of Projection
  265.   4.4.3Focal Blur
  266.   4.4.4Camera Ray Perturbation
  267.   4.4.5Camera Identifiers
  268.  4.5Objects
  269.   4.5.1Finite Solid Primitives
  270.     4.5.1.1   Blob
  271.     4.5.1.2   Box
  272.     4.5.1.3   Cone
  273.     4.5.1.4   Cylinder
  274.     4.5.1.5   Height Field
  275.     4.5.1.6   Julia Fractal
  276.     4.5.1.7   Lathe
  277.     4.5.1.8   Prism
  278.     4.5.1.9   Sphere
  279.     4.5.1.10  Superquadric Ellipsoid
  280.     4.5.1.11  Surface of Revolution
  281.     4.5.1.12  Text
  282.     4.5.1.13  Torus
  283.   4.5.2Finite Patch Primitives
  284.     4.5.2.1   Bicubic Patch
  285.     4.5.2.2   Disc
  286.     4.5.2.3   Mesh
  287.     4.5.2.4   Polygon
  288.     4.5.2.5   Triangle and Smooth Triangle
  289.   4.5.3Infinite Solid Primitives
  290.     4.5.3.1   Plane
  291.     4.5.3.2   Poly, Cubic and Quartic
  292.     4.5.3.3   Quadric
  293.   4.5.4Constructive Solid Geometry
  294.     4.5.4.1   Inside and Outside
  295.     4.5.4.2   Union
  296.     4.5.4.3   Intersection
  297.     4.5.4.4   Difference
  298.     4.5.4.5   Merge
  299.   4.5.5Light Sources
  300.     4.5.5.1   Point Lights
  301.     4.5.5.2   Spotlights
  302.     4.5.5.3   Cylindrical Lights
  303.     4.5.5.4   Area Lights
  304.     4.5.5.5   Shadowless Lights
  305.     4.5.5.6   Looks_like
  306.     4.5.5.7   Light Fading
  307.     4.5.5.8   Atmospheric Media Interaction
  308.     4.5.5.9   Atmospheric Attenuation
  309.   4.5.6Object Modifiers
  310.     4.5.6.1   Clipped_By
  311.     4.5.6.2   Bounded_By
  312.     4.5.6.3   Material
  313.     4.5.6.4   Inverse
  314.     4.5.6.5   Hollow
  315.     4.5.6.6   No_Shadow
  316.     4.5.6.7   Sturm
  317.  4.6Interior
  318.   4.6.1Why are Interior and Media Necessary?
  319.   4.6.2Empty and Solid Objects
  320.   4.6.3Refraction
  321.   4.6.4Attenuation
  322.   4.6.5Faked Caustics
  323.   4.6.6Object Media
  324.  4.7Textures
  325.   4.7.1Pigment
  326.     4.7.1.1   Solid Color Pigments
  327.     4.7.1.2   Color List Pigments
  328.     4.7.1.3   Color Maps
  329.     4.7.1.4   Pigment Maps and Pigment Lists
  330.     4.7.1.5   Image Maps
  331.      4.7.1.5.1                          Specifying an Image Map
  332.      4.7.1.5.2         The Filter and Transmit Bitmap Modifiers
  333.      4.7.1.5.3                          Using the Alpha Channel
  334.     4.7.1.6   Quick Color
  335.   4.7.2Normal
  336.     4.7.2.1   Slope Maps
  337.     4.7.2.2   Normal Maps and Normal Lists
  338.     4.7.2.3   Bump Maps
  339.      4.7.2.3.1                            Specifying a Bump Map
  340.      4.7.2.3.2                                        Bump_Size
  341.      4.7.2.3.3                          Use_Index and Use_Color
  342.   4.7.3Finish
  343.     4.7.3.1   Ambient
  344.     4.7.3.2   Diffuse Reflection Items
  345.      4.7.3.2.1                                          Diffuse
  346.      4.7.3.2.2                                       Brilliance
  347.      4.7.3.2.3                                 Crand Graininess
  348.     4.7.3.3   Highlights
  349.      4.7.3.3.1                                 Phong Highlights
  350.      4.7.3.3.2                               Specular Highlight
  351.      4.7.3.3.3                      Metallic Highlight Modifier
  352.     4.7.3.4   Specular Reflection
  353.     4.7.3.5   Iridescence
  354.   4.7.4Halo
  355.   4.7.5Patterned Textures
  356.     4.7.5.1   Texture Maps
  357.     4.7.5.2   Tiles
  358.     4.7.5.3   Material Maps
  359.      4.7.5.3.1                        Specifying a Material Map
  360.   4.7.6Layered Textures
  361.   4.7.7Patterns
  362.     4.7.7.1   Agate
  363.     4.7.7.2   Average
  364.     4.7.7.3   Boxed
  365.     4.7.7.4   Bozo
  366.     4.7.7.5   Brick
  367.     4.7.7.6   Bumps
  368.     4.7.7.7   Checker
  369.     4.7.7.8   Crackle
  370.     4.7.7.9   Cylindrical
  371.     4.7.7.10  Density_File
  372.     4.7.7.11  Dents
  373.     4.7.7.12  Gradient
  374.     4.7.7.13  Granite
  375.     4.7.7.14  Hexagon
  376.     4.7.7.15  Leopard
  377.     4.7.7.16  Mandel
  378.     4.7.7.17  Marble
  379.     4.7.7.18  Onion
  380.     4.7.7.19  Planar
  381.     4.7.7.20  Quilted
  382.     4.7.7.21  Radial
  383.     4.7.7.22  Ripples
  384.     4.7.7.23  Spherical
  385.     4.7.7.24  Spiral1
  386.     4.7.7.25  Spiral2
  387.     4.7.7.26  Spotted
  388.     4.7.7.27  Waves
  389.     4.7.7.28  Wood
  390.     4.7.7.29  Wrinkles
  391.   4.7.8Pattern Modifiers
  392.     4.7.8.1   Transforming Patterns
  393.     4.7.8.2   Frequency and Phase
  394.     4.7.8.3   Waveforms
  395.     4.7.8.4   Turbulence
  396.     4.7.8.5   Octaves
  397.     4.7.8.6   Lambda
  398.     4.7.8.7   Omega
  399.     4.7.8.8   Warps
  400.      4.7.8.8.1                                  Black Hole Warp
  401.      4.7.8.8.2                                      Repeat Warp
  402.      4.7.8.8.3                                  Turbulence Warp
  403.     4.7.8.9   Bitmap Modifiers
  404.      4.7.8.9.1                                  The once Option
  405.      4.7.8.9.2                              The map_type Option
  406.      4.7.8.9.3                           The interpolate Option
  407.  4.8Media
  408.   4.8.1Media Types
  409.     4.8.1.1   Absorption
  410.     4.8.1.2   Emission
  411.     4.8.1.3   Scattering
  412.   4.8.2Sampling Parameters
  413.   4.8.3Density
  414.     4.8.3.1   General Density Modifiers
  415.     4.8.3.2   Density with color_map
  416.     4.8.3.3   Density Maps and Density Lists
  417.     4.8.3.4   Multiple Density vs. Multiple Media
  418.  4.9Atmospheric Effects
  419.   4.9.1Atmospheric Media
  420.   4.9.2Background
  421.   4.9.3Fog
  422.   4.9.4Sky Sphere
  423.   4.9.5Rainbow
  424.  4.10                                           Global Settings
  425.   4.10.1                                            ADC_Bailout
  426.   4.10.2                                          Ambient Light
  427.   4.10.3                                          Assumed_Gamma
  428.     4.10.3.1  Monitor Gamma
  429.     4.10.3.2  Image File Gamma
  430.     4.10.3.3  Scene File Gamma
  431.   4.10.4                                             HF_Gray_16
  432.   4.10.5                                        Irid_Wavelength
  433.   4.10.6                                        Max_Trace_Level
  434.   4.10.7                                      Max_Intersections
  435.   4.10.8                                        Number_Of_Waves
  436.   4.10.9                                              Radiosity
  437.     4.10.9.1  How Radiosity Works
  438.     4.10.9.2  Adjusting Radiosity
  439.      4.10.9.2.1                                      brightness
  440.      4.10.9.2.2                                           count
  441.      4.10.9.2.3                                distance_maximum
  442.      4.10.9.2.4                                     error_bound
  443.      4.10.9.2.5                                  gray_threshold
  444.      4.10.9.2.6                                low_error_factor
  445.      4.10.9.2.7                                   minimum_reuse
  446.      4.10.9.2.8                                   nearest_count
  447.      4.10.9.2.9                                 recursion_limit
  448.     4.10.9.3  Tips on Radiosity
  449. 5 APPENDICES
  450.  5.1Copyright, Legal Information and License -- POVLEGAL.DOC
  451.   5.1.1General License Agreement -- POVLEGAL.DOC
  452.   5.1.2Usage Provisions
  453.   5.1.3General Rules For All Distribution
  454.   5.1.4Definition Of "Full Package"
  455.   5.1.5Conditions For Shareware/Freeware Distribution Companies
  456.   5.1.6Conditions For On-Line Services And Bbs's Including
  457.   Internet
  458.   5.1.7Online Or Remote Execution Of POV-Ray
  459.   5.1.8Permitted Modification And Custom Versions
  460.   5.1.9Conditions For Distribution Of Custom Versions
  461.   5.1.10                     Conditions For Commercial Bundling
  462.   5.1.11                      POV-Team Endorsement Prohibitions
  463.   5.1.12                          Retail Value Of This Software
  464.   5.1.13                                       Other Provisions
  465.   5.1.14                                  Revocation Of License
  466.   5.1.15                                             Disclaimer
  467.   5.1.16                                      Technical Support
  468.  5.2Authors
  469.   5.2.1Contacting the Authors
  470.  5.3What to do if you don't have POV-Ray
  471.   5.3.1Which Version of POV-Ray should you use?
  472.     5.3.1.1   Microsoft Windows 95/98/NT
  473.     5.3.1.2   MS-Dos & Windows 3.x
  474.     5.3.1.3   Linux for Intel x86
  475.     5.3.1.4   Apple Macintosh
  476.     5.3.1.5   Amiga
  477.     5.3.1.6   SunOS
  478.     5.3.1.7   Generic Unix
  479.     5.3.1.8   All Versions
  480.   5.3.2Where to Find POV-Ray Files
  481.     5.3.2.1   POV-Ray Forum on CompuServe
  482.     5.3.2.2   World Wide Website www.povray.org
  483.     5.3.2.3   Books, Magazines and CD-ROMs
  484.  5.4Compiling POV-Ray
  485.   5.4.1Directory Structure
  486.   5.4.2Configuring POV-Ray Source
  487.   5.4.3Conclusion
  488.  5.5Suggested Reading
  489.  
  490.  
  491.  
  492. 1    Introduction
  493. This document details the use of the Persistence of Vision (tm) Ray-
  494. Tracer (POV-Ray (tm)). It is divided into five parts:
  495.  
  496.   1)This introduction which explains what POV-Ray is and what
  497.      ray-tracing is. It gives a brief overview of how to create
  498.      ray-traced images.
  499.   2)A "Beginning Tutorial" which explains step by step how to
  500.      use the different features of POV-Ray.
  501.   3)A complete reference on "Scene Description Language" in
  502.      which you describe the scene.
  503.   4)A complete reference on "POV-Ray Options" which explains
  504.      options (set either by command line switches or by INI file
  505.      keywords) that tell POV-Ray how to render the scenes.
  506.   5)And in our "APPENDICES" you will find some tips and hints,
  507.      where to get the latest version and versions for other
  508.      platforms, information on compiling custom versions of POV-
  509.      Ray, suggested reading, contact addresses and legal
  510.      information.
  511. POV-Ray runs on MS-Dos, Windows 3.x, Windows for Workgroups 3.11,
  512. Windows 95, Windows NT, Apple Macintosh 68k, Macintosh Power PC,
  513. Amiga, Linux, Sun-OS, UNIX and other platforms.
  514.  
  515. We assume that if you are reading this document then you already
  516. have POV-Ray installed and running.  However the POV-Team does
  517. distribute this file by itself in various formats including
  518. online on the internet.  If you don't have POV-Ray or aren't sure
  519. you have the official version or the latest version, see appendix
  520. "What to do if you don't have POV-Ray".
  521.  
  522. This document covers only the generic parts of the program which
  523. are common to each version.  Each version has platform-specific
  524. documentation not included here.  We recommend you finish reading
  525. this introductory section then read the platform-specific
  526. information before trying the tutorial here.
  527.  
  528. The platform-specific docs will show you how to render a sample
  529. scene and will give you detailed description of the platform-
  530. specific features.
  531.  
  532. The MS-Dos version documentation contains a plain text file
  533. POVMSDOS.DOC which contains its specific docs.  It can be found
  534. in the main directory where you installed POV-Ray such as
  535. C:\POVRAY3.
  536.  
  537. The Windows version documentation is available on the POV-Ray
  538. program's Help menu or press the F1 key while in the program.
  539.  
  540. The Mac platform documentation consists of a self-displaying
  541. document called "POV-Ray MacOS Read Me" which contains
  542. information specific to the Mac version of POV-Ray. It is best to
  543. read this document first, to learn how to set up and start using
  544. the Mac version of POV-Ray. This document is in the
  545. "Documentation" folder in the main "POV-Ray 3" folder.
  546.  
  547. The Amiga version documentation is made up of Html documents,
  548. stored in the same place of general POV-Ray docs; the 'root'
  549. document is "POVRAY3:POV-Reference/AmigaPOV.html" when the
  550. program is installed following the instruction given.  Amiga
  551. specific documentation and POV-Ray general docs are available
  552. pressing Help key in the POV-Gui program; this feature is
  553. available in POV-Gui since version 2.1
  554.  
  555. The Linux version documentation contains a plain text file
  556. povlinux.doc which contains its specific docs.  It can be found
  557. in the main directory where you installed POV-Ray such as
  558. /usr/povray3.
  559.  
  560. The SunOS version documentation contains a plain text file
  561. povsunos.doc which contains its specific docs.  It can be found
  562. in the main directory where you installed POV-Ray such as
  563. /usr/povray3.
  564.  
  565. The generic Unix version documentation contains a plain text file
  566. povunix.doc which contains its specific docs.  It can be found in
  567. the main directory where you installed POV-Ray such as
  568. /usr/povray3.
  569.  
  570.  
  571. 1.1  Program Description
  572. The Persistence of Vision(tm) Ray-Tracer creates three-dimensional,
  573. photo-realistic images using a rendering technique called ray-
  574. tracing. It reads in a text file containing information
  575. describing the objects and lighting in a scene and generates an
  576. image of that scene from the view point of a camera also
  577. described in the text file. Ray-tracing is not a fast process by
  578. any means, but it produces very high quality images with
  579. realistic reflections, shading, perspective and other effects.
  580.  
  581.  
  582. 1.2  What is Ray-Tracing?
  583. Ray-tracing is a rendering technique that calculates an image of
  584. a scene by simulating the way rays of light travel in the real
  585. world.  However it does its job backwards.  In the real world,
  586. rays of light are emitted from a light source and illuminate
  587. objects.  The light reflects off of the objects or passes through
  588. transparent objects.  This reflected light hits our eyes or
  589. perhaps a camera lens.  Because the vast majority of rays never
  590. hit an observer, it would take forever to trace a scene.
  591.  
  592. Ray-tracing programs like POV-Ray start with their simulated
  593. camera and trace rays backwards out into the scene.  The user
  594. specifies the location of the camera, light sources, and objects
  595. as well as the surface texture properties of objects, their
  596. interiors (if transparent) and any atmospheric media such as fog,
  597. haze, or fire.
  598.  
  599. For every pixel in the final image one or more viewing rays are
  600. shot from the camera, into the scene to see if it intersects with
  601. any of the objects in the scene. These "viewing rays" originate
  602. from the viewer, represented by the camera, and pass through the
  603. viewing window (representing the final image).
  604.  
  605. Every time an object is hit, the color of the surface at that
  606. point is calculated. For this purpose rays are sent backwards to
  607. each light source to determine the amount of light coming from
  608. the source. These "shadow rays" are tested to tell whether the
  609. surface point lies in shadow or not. If the surface is reflective
  610. or transparent new rays are set up and traced in order to
  611. determine the contribution of the reflected and refracted light
  612. to the final surface color.
  613.  
  614. Special features like inter-diffuse reflection (radiosity),
  615. atmospheric effects and area lights make it necessary to shoot a
  616. lot of additional rays into the scene for every pixel.
  617.  
  618.  
  619. 1.3  What is POV-Ray?
  620. The Persistence of Vision (tm) Ray-Tracer was developed from
  621. DKBTrace 2.12 (written by David K. Buck and Aaron A. Collins) by
  622. a bunch of people, called the POV-Team (tm), in their spare time.
  623. The headquarters of the POV-Team is in the POVRAY forum on
  624. CompuServe (see "POV-Ray Forum on CompuServe" for more details).
  625.  
  626. The POV-Ray (tm) package includes detailed instructions on using the
  627. ray-tracer and creating scenes. Many stunning scenes are included
  628. with POV-Ray so you can start creating images immediately when
  629. you get the package. These scenes can be modified so you don't
  630. have to start from scratch.
  631.  
  632. In addition to the pre-defined scenes, a large library of pre-
  633. defined shapes and materials is provided.  You can include these
  634. shapes and materials in your own scenes by just including the
  635. library file name at the top of your scene file, and by using the
  636. shape or material name in your scene.
  637.  
  638. Here are some highlights of POV-Ray's features:
  639.  
  640.   * Easy to use scene description language.
  641.   * Large library of stunning example scene files.
  642.   * Standard include files that pre-define many shapes, colors
  643.   and textures.
  644.   * Very high quality output image files (up to 48-bit color).
  645.   * 15 and 24 bit color display on many computer platforms using
  646.   appropriate hardware.
  647.   * Create landscapes using smoothed height fields.
  648.   * Many camera types, including perspective, panorama,
  649.   orthographic, fisheye, etc.
  650.   * Spotlights, cylindrical lights and area lights for
  651.   sophisticated  lighting.
  652.   * Phong and specular highlighting for more realistic-looking
  653.   surfaces.
  654.   * Inter-diffuse reflection (radiosity) for more realistic
  655.   lighting.
  656.   * Atmospheric effects like atmosphere, ground-fog and rainbow.
  657.   * Particle media to model effects like clouds, dust, fire and
  658.   steam.
  659.   * Several image file output formats including Targa, PNG and
  660.   PPM.
  661.   * Basic shape primitives such as ... spheres, boxes, quadrics,
  662.   cylinders, cones, triangles and planes.
  663.   * Advanced shape primitives such as ... Torii (donuts), bezier
  664.   patches, height fields (mountains), blobs, quartics, smooth
  665.   triangles, text, fractals, superquadrics, surfaces of
  666.   revolution, prisms, polygons, lathes and fractals.
  667.   * Shapes can easily be combined to create new complex shapes
  668.   using Constructive Solid Geometry (CSG). POV-Ray supports
  669.   unions, merges, intersections and differences.
  670.   * Objects are assigned materials called textures (a texture
  671.   describes the coloring and surface properties of a shape) and
  672.   interior properties such as index of refraction and particle
  673.   media (formerly known as "halos").
  674.   * Built-in color and normal patterns: Agate, Bozo, Bumps,
  675.   Checker, Crackle, Dents, Granite, Gradient, Hexagon, Leopard,
  676.   Mandel, Marble, Onion, Quilted, Ripples, Spotted, Spiral,
  677.   Radial, Waves, Wood, Wrinkles and image file mapping.
  678.   * Users can create their own textures or use pre-defined
  679.   textures such as ... Brass, Chrome, Copper, Gold, Silver,
  680.   Stone, Wood.
  681.   * Combine textures using layering of semi-transparent textures
  682.   or tiles of textures or material map files.
  683.   * Display preview of image while rendering (not available on
  684.   all platforms).
  685.   * Halt and save a render part way through, and continue
  686.   rendering the halted partial render later.
  687.  
  688. 1.4  How Do I Begin?
  689. POV-Ray scenes are described in a special text language called a
  690. "scene description language".  You will type commands into a
  691. plain text file and POV-Ray will read it to create the image.
  692. The process of running POV-Ray is a little different on each
  693. platform or operating system.  You should read the platform-
  694. specific documentation as suggested earlier in this introduction.
  695. It will tell you how to command POV-Ray to turn your text scene
  696. description into an image.  You should try rendering several
  697. sample images before attempting to create your own.
  698.  
  699. Once you know how to run POV-Ray on your computer and your
  700. operating system, you can proceed with the tutorial which
  701. follows.  The tutorial explains how to describe the scene using
  702. the POV-Ray language.
  703.  
  704.  
  705. 1.5  Notation and Basic Assumptions
  706. Throughout the tutorial and reference section of this document,
  707. the following notation is used to mark keywords of the scene
  708. description language, command line switches, INI file keywords
  709. and file names.
  710.      keyword       mono-spaced bold    POV-Ray keywords and
  711.                                        punctuation
  712.      +W640 +H480   mono-spaced bold    command-line switches
  713.      C:\MYFILE.PO  mono-spaced         file names,
  714.      V                                 directories, paths
  715.      SYNTAX_ITEM   italics, all caps   required syntax item
  716.      [SYNTAX_ITEM  italics, all caps,  optional syntax item
  717.      ]             braces
  718.      SYNTAX_ITEM.  italics, all caps,  one or more syntax
  719.      ..            ellipsis            items
  720.      [SYNTAX_ITEM  italics, all caps,  zero or more syntax
  721.      ...]          braces, ellipsis    items
  722.      Value_1       italics, mixed      a float value or
  723.                    case                expression
  724.      <Value_1>     italics, mixed      a vector value or
  725.                    case, angle braces  expression
  726.      [ ITEM ]      bold square braces  ITEM enclosed in
  727.                                        required braces
  728.      ITEM1   |     vertical bar        choice of ITEM1 or
  729.      ITEM2                             ITEM2
  730.                                 
  731.                                 
  732. In the plain ASCII version of the document there is no visible
  733. difference between the different notations.
  734.  
  735. Note that POV-Ray is a command-line program on MS-Dos, Unix and
  736. other text-based operating system and is menu-driven on Windows
  737. and Macintosh platforms.  Some of these operating systems use
  738. folders to store files while others use directories.  Some
  739. separate the folders and sub-folders with a slash character (/),
  740. back-slash character (\), or others.  We have tried to make this
  741. documentation as generic as possible but sometimes we have to
  742. refer to folders, files, options etc. and there's no way to
  743. escape it. Here are some assumptions we make...
  744.  
  745. 1) You installed POV-Ray in the "C:\POVRAY3" directory.  For MS-
  746. Dos this is probably true but for Unix it might be
  747. "/usr/povray3", or for Windows it might be "C:\Program Files\POV-
  748. Ray for Windows", for Mac it might be "MyHD:Apps:POV-Ray 3:", or
  749. you may have used some other drive or directory.  So if we tell
  750. you that "Include files are stored in the \povray3\include
  751. directory,"  we assume you can translate that to something like
  752. "::POVRAY3:INCLUDE" or "C:\Program Files\POV-Ray for
  753. Windows\include" or whatever is appropriate for your platform,
  754. operating system and installation.
  755.  
  756. 2) POV-Ray uses command-line switches and INI files to choose
  757. options in all versions but Windows and Mac also use dialog boxes
  758. or menu choices to set options.  We will describe options
  759. assuming you are using switches or INI files when describing what
  760. the options do. We have taken care to use the same terminology in
  761. designing menus and dialogs as we use in describing switches or
  762. INI keywords. See your version-specific documentation on menu and
  763. dialogs.
  764.  
  765. 3) Some of you are reading this using a help-reader, built-in
  766. help, web-browser, formatted printout, or plain text file.  We
  767. assume you know how to get around in which ever medium you're
  768. using.  We'll say "See the chapter on "Setting POV-Ray Option" we
  769. assume you can click, scroll, browse, flip pages or whatever to
  770. get there.
  771.  
  772.  
  773. 1.6  What's New in POV-Ray 3.1?
  774. Here is an overview of what is new in POV-Ray 3.1 since version
  775. 3.0.
  776.  
  777.  
  778. 1.6.1     Media Replaces Halo & Atmosphere
  779. The keywords halo and atmosphere have been totally eliminated
  780. with no backwards compatibility of any kind provided. They have
  781. been replaced by a new feature called media.  At the scene level,
  782. media acts as atmospheric media for fog, haze, dust, etc.  On
  783. objects, media is not part of texture like halo was. Object media
  784. is now part of a new feature called interior.  Media is not just
  785. a rename for halo.  It is a new model with some similar features
  786. of halo.  BECAUSE POV-Ray 3.1 DISCONTINUES SOME 3.0 FEATURES YOU
  787. MAY WISH TO KEEP 3.0 TO RENDER OLDER SCENES.
  788.  
  789. Any pattern type (bozo, wood, dents, etc.) may be used as a
  790. density function for media.
  791.  
  792. New patterns spherical, cylindrical, planar, and boxed added for
  793. pigment, normal, texture, and density.
  794.  
  795. New wave types cubic_wave and poly_wave Float have been added.
  796.  
  797. New object modifier interior{...}.  Interior contains information
  798. about the interior of the object which was formerly contained in
  799. the finish and halo parts of a texture. Interior items are no
  800. longer part of the texture.  Instead, they attach directly to the
  801. objects. The finish items moved are ior, caustic, fade_power, and
  802. fade_distance.  The refraction keyword is no longer necessary.
  803. Any ior other than 1.0 turns on refraction.  These 5 finish
  804. keywords which are now part of interior will still work in finish
  805. but will generate warnings.  Some obscure texture_map statements
  806. with varying ior will not work.
  807.  
  808. Added reflection_exponent Float to finish to give more realistic
  809. reflection of very bright objects.
  810.  
  811.  
  812. 1.6.2     New #macro Feature
  813. Add fully recursive and parameterized #macro directive.  Define
  814. like this...
  815.  
  816.   #macro MyMacro (P1,P2,P3)   ...  #end
  817. Invoke like this...
  818.  
  819.   MyMacro (5,x*5,MyTexture)
  820. Note no '#' sign precedes invocation.  Macros can be invoked
  821. almost anywhere. Parameters must be identifiers or any item that
  822. can be declared, MyMacro(pigment{Green},MyObject) for example.
  823.  
  824. Added #local IDENTIFIER= STATEMENT as alternative to #declare to
  825. create temporary local identifier in macros or include files.
  826.  
  827.  
  828. 1.6.3     Arrays Added
  829. Added multi-dimension arrays
  830.  
  831.   #declare MyArray=array[20]
  832.  or
  833.  
  834.   #local PrivateArray=array[30]
  835.  or
  836.  
  837.   #declare Rows=5; #declare Cols=4;
  838.   #declare Table=array[Rows][Cols]
  839. Added optional initializer syntax for arrays.
  840.  
  841.  #declare MyArray=array[2][3]{{1,2,3},{4,5,6}}
  842. Subscripts start at 0.  Anything that can be declared may be in
  843. an array. Arrays are initialized as null.  You must later fill
  844. each element with values.
  845.  
  846. Added float functions for arrays.  Given #declare MyArray =
  847. array[4][5] then dimensions(MyArray) is 2 and
  848. dimension_size(MyArray,2) is 5.
  849.  
  850.  
  851. 1.6.4     File I/O and other Directives
  852. Added #fopen, #fclose, #read, and #write directives for user text
  853. files.
  854.  
  855. Added #undef identifier directive.  Un-declares previously
  856. declared identifier.  Works on locals or globals.
  857.  
  858. Added requirement that any directive which can end in a float or
  859. expression must be terminated by a semi-colon.  Specifically this
  860. means any #declare or #local of float, vector or color or the
  861. #version directive.
  862.  
  863.  
  864. 1.6.5     Additional New Features
  865. Added Bezier splines to lathe and prism. The spline is made of
  866. segments having four points each. Thus there are always four
  867. times the number of  segments in a prism or lathe. A four point
  868. Bezier spline uses 3rd order Bernstein blending functions which
  869. are sufficient for smooth curves.
  870.  
  871. Added float constant clock_delta returns time between frames.
  872.  
  873.  
  874. 2    Beginning Tutorial
  875. The beginning tutorial explains step by step how to use POV-Ray's
  876. scene description language to create own your scenes. The use of
  877. almost every feature of POV-Ray's language is explained in
  878. detail. We will learn basic things like placing cameras and light
  879. sources. We will also learn how to create a large variety of
  880. objects and how to assign different textures to them. The more
  881. sophisticated features like radiosity, interior, media and
  882. atmospheric effects will be explained in detail.
  883.  
  884.  
  885. 2.1  Our First Image
  886. We will create the scene file for a simple picture. Since ray-
  887. tracers thrive on spheres, that is what we will render first.
  888.  
  889.  
  890. 2.1.1     Understanding POV-Ray's Coordinate System
  891. First, we have to tell POV-Ray where our camera is and where it
  892. is looking. To do this, we use 3D coordinates. The usual
  893. coordinate system for POV-Ray has the positive y-axis pointing
  894. up, the positive x-axis pointing to the right, and the positive z-
  895. axis pointing into the screen as follows:
  896.  
  897.                                 
  898.                                 
  899.  The left-handed coordinate system (the z-axis is pointing away)
  900. This kind of coordinate system is called a left-handed coordinate
  901. system. If we use our left hand's fingers we can easily see why
  902. it is called left-handed. We just point our thumb in the
  903. direction of the positive x-axis (to the right), the index finger
  904. in the direction of the positive y-axis (straight up) and the
  905. middle finger in the positive z-axis direction (forward). We can
  906. only do this with our left hand. If we had used our right hand we
  907. would not have been able to point the middle finger in the
  908. correct direction.
  909.  
  910. The left hand can also be used to determine rotation directions.
  911. To do this we must perform the famous "Computer Graphics
  912. Aerobics" exercise. We hold up our left hand and point our thumb
  913. in the positive direction of the axis of rotation. Our fingers
  914. will curl in the positive direction of rotation. Similarly if we
  915. point our thumb in the negative direction of the axis our fingers
  916. will curl in the negative direction of rotation.
  917.  
  918.                                 
  919.                                 
  920. "Computer Graphics Aerobics" to determine the rotation direction.
  921. In the above illustration, the left hand is curling around the x-
  922. axis. The thumb points in the positive x direction and the
  923. fingers curl over in the positive rotation direction.
  924.  
  925. If we want to use a right-handed system, as some CAD systems and
  926. modelers do, the right vector in the camera specification needs
  927. to be changed. See the detailed description in "Handedness". In a
  928. right-handed system we use our right hand for the "Aerobics".
  929.  
  930. There is some controversy over whether POV-Ray's method of doing
  931. a right-handed system is really proper. To avoid problems we
  932. stick with the left-handed system which is not in dispute.
  933.  
  934.  
  935. 2.1.2     Adding Standard Include Files
  936. Using our personal favorite text editor, we create a file called
  937. demo.pov. Note some versions of POV-Ray come with their own built-
  938. in text editor which may be easier to use. We then type in the
  939. following text. The input is case sensitive, so we have to be
  940. sure to get capital and lowercase letters correct.
  941.  
  942.   #include "colors.inc"    // The include files contain
  943.   #include "stones.inc"    // pre-defined scene elements
  944. The first include statement reads in definitions for various
  945. useful colors. The second include statement reads in a collection
  946. of stone textures.
  947.  
  948. POV-Ray comes with many standard include files.  Others of
  949. interest are:
  950.  
  951.   #include "textures.inc"    // pre-defined scene elements
  952.   #include "shapes.inc"
  953.   #include "glass.inc"
  954.   #include "metals.inc"
  955.   #include "woods.inc"
  956. They read pre-defined textures, shapes, glass, metal, and wood
  957. textures. It is a good idea to have a look through them to see a
  958. few of the many possible shapes and textures available.
  959.  
  960. We should only include files we really need in our scene. Some of
  961. the include files coming with POV-Ray are quite large and we
  962. should better save the parsing time and memory if we don't need
  963. them. In the following examples we will only use the colors.inc,
  964. and stones.inc include files.
  965.  
  966. We may have as many include files as needed in a scene file.
  967. Include files may themselves contain include files, but we are
  968. limited to declaring includes nested only ten levels deep.
  969.  
  970. Filenames specified in the include statements will be searched
  971. for in the current directory first. If it fails to find your .Inc
  972. files in the current directory, POV-Ray searches any "library
  973. paths" that you have specified.  Library paths are options set by
  974. the +L command-line switch or Library_Path option. See the
  975. chapter "Setting POV-Ray Options" for more information on library
  976. paths.
  977.  
  978. Because it is more useful to keep include files in a separate
  979. directory, standard installation of POV-Ray place these files in
  980. the \povray3\include directory.  If you get an error message
  981. saying that POV-Ray cannot open "colors.inc" or other include
  982. files, make sure that you specify the library path properly.
  983.  
  984.  
  985. 2.1.3     Adding a Camera
  986. The camera statement describes where and how the camera sees the
  987. scene. It gives x-, y- and z-coordinates to indicate the position
  988. of the camera and what part of the scene it is pointing at.  We
  989. describe the coordinates using a three-part vector. A vector is
  990. specified by putting three numeric values between a pair of angle
  991. brackets and separating the values with commas.
  992.  
  993. We add the following camera statement to the scene.
  994.  
  995.   camera {
  996.     location <0, 2, -3>
  997.     look_at  <0, 1,  2>
  998.   }
  999. Briefly, location <0,2,-3> places the camera up two units and
  1000. back three units from the center of the ray-tracing universe
  1001. which is at <0,0,0>. By default +z is into the screen and -z is
  1002. back out of the screen.
  1003.  
  1004. Also look_at <0,1,2> rotates the camera to point at the
  1005. coordinates <0,1,2>. A point 1 unit up from the origin and 2
  1006. units away from the origin.  This makes it 5 units in front of
  1007. and 1 unit lower than the camera. The look_at point should be the
  1008. center of attention of our image.
  1009.  
  1010.  
  1011. 2.1.4     Describing an Object
  1012. Now that the camera is set up to record the scene, let's place a
  1013. yellow sphere into the scene. We add the following to our scene
  1014. file:
  1015.  
  1016.   sphere {
  1017.     <0, 1, 2>, 2
  1018.     texture {
  1019.       pigment { color Yellow }
  1020.     }
  1021.   }
  1022. The first vector specifies the center of the sphere. In this
  1023. example the x coordinate is zero so it is centered left and
  1024. right. It is also at y=1 or one unit up from the origin. The z
  1025. coordinate is 2 which is five units in front of the camera, which
  1026. is at z=-3. After the center vector is a comma followed by the
  1027. radius which in this case is two units. Since the radius is half
  1028. the width of a sphere, the sphere is four units wide.
  1029.  
  1030.  
  1031. 2.1.5     Adding Texture to an Object
  1032. After we have defined the location and size of the sphere, we
  1033. need to describe the appearance of the surface. The texture
  1034. statement specifies these parameters. Texture blocks describe the
  1035. color, bumpiness and finish properties of an object. In this
  1036. example we will specify the color only. This is the minimum we
  1037. must do. All other texture options except color will use default
  1038. values.
  1039.  
  1040. The color we define is the way we want an object to look if fully
  1041. illuminated. If we were painting a picture of a sphere we would
  1042. use dark shades of a color to indicate the shadowed side and
  1043. bright shades on the illuminated side. However ray-tracing takes
  1044. care of that for you. We only need to pick the basic color
  1045. inherent in the object and POV-Ray brightens or darkens it
  1046. depending on the lighting in the scene. Because we are defining
  1047. the basic color the object actually has rather than how it looks
  1048. the parameter is called pigment.
  1049.  
  1050. Many types of color patterns are available for use in a pigment
  1051. statement. The keyword color specifies that the whole object is
  1052. to be one solid color rather than some pattern of colors. We can
  1053. use one of the color identifiers previously defined in the
  1054. standard include file colors.inc.
  1055.  
  1056. If no standard color is available for our needs, we may define
  1057. our own color by using the color keyword followed by red, green,
  1058. and blue keywords specifying the amount of red, green and blue to
  1059. be mixed. For example a nice shade of pink can be specified by:
  1060.  
  1061.   color red 1.0 green 0.8 blue 0.8
  1062. The values after each keyword should be in the range from 0.0 to
  1063. 1.0. Any of the three components not specified will default to 0.
  1064. A shortcut notation may also be used. The following produces the
  1065. same shade of pink:
  1066.  
  1067.   color rgb <1.0, 0.8, 0.8>
  1068. Colors are explained in more detail in section "Specifying
  1069. Colors".
  1070.  
  1071.  
  1072. 2.1.6     Defining a Light Source
  1073. One more detail is needed for our scene. We need a light source.
  1074. Until we create one, there is no light in this virtual world.
  1075. Thus we add the line
  1076.  
  1077. Thus we add the line
  1078.  
  1079.   light_source { <2, 4, -3> color White}
  1080. to the scene file to get our first complete POV-Ray scene file as
  1081. shown below.
  1082.  
  1083.   #include "colors.inc"
  1084.   background { color Cyan }
  1085.   camera {
  1086.     location <0, 2, -3>
  1087.     look_at  <0, 1,  2>
  1088.   }
  1089.   sphere {
  1090.     <0, 1, 2>, 2
  1091.     texture {
  1092.       pigment { color Yellow }
  1093.     }
  1094.   }
  1095.   light_source { <2, 4, -3> color White}
  1096. The vector in the light_source statement specifies the location
  1097. of the light as two units to our right, four units above the
  1098. origin and three units back from the origin. The light source is
  1099. an invisible tiny point that emits light.  It has no physical
  1100. shape, so no texture is needed.
  1101.  
  1102. That's it! We close the file and render a small picture of it
  1103. using whatever methods you used for your particular platform.  If
  1104. you specified a preview display it will appear on your screen.
  1105. If you specified an output file (the default is file output on),
  1106. then POV-Ray also created a file.  Note that if you do not have
  1107. high color or true color display hardware then the preview image
  1108. may look poor but the full detail is written to the image file
  1109. regardless of the type of display.
  1110.  
  1111. The scene we just traced isn't quite state of the art but we will
  1112. have to start with the basics before we soon get to much more
  1113. fascinating features and scenes.
  1114.  
  1115.  
  1116. 2.2  Simple Shapes
  1117. So far we have just used the sphere shape. There are many other
  1118. types of shapes that can be rendered by POV-Ray. The following
  1119. sections will describe how to use some of the more simple objects
  1120. as a replacement for the sphere used above.
  1121.  
  1122.  
  1123. 2.2.1     Box Object
  1124. The box is one of the most common objects used. We try this
  1125. example in place of the sphere:
  1126.  
  1127.   box {
  1128.     <-1, 0,   -1>,  // Near lower left corner
  1129.     < 1, 0.5,  3>   // Far upper right corner
  1130.     texture {
  1131.       T_Stone25     // Pre-defined from stones.inc
  1132.       scale 4       // Scale by the same amount in all
  1133.                     // directions
  1134.     }
  1135.     rotate y*20     // Equivalent to "rotate <0,20,0>"
  1136.   }
  1137. In the example we can see that a box is defined by specifying the
  1138. 3D coordinates of its opposite corners. The first vector is
  1139. generally  the minimum x-, y- and z-coordinates and the 2nd
  1140. vector should be the maximum x-, y- and z-values however any two
  1141. opposite corners may be used. Box objects can only be defined
  1142. parallel to the axes of the world coordinate system. We can later
  1143. rotate them to any angle. Note that we can perform simple math on
  1144. values and vectors. In the rotate parameter we multiplied the
  1145. vector identifier y by 20. This is the same as <0,1,0>*20 or
  1146. <0,20,0>.
  1147.  
  1148.  
  1149. 2.2.2     Cone Object
  1150. Here's another example showing how to use a cone:
  1151.  
  1152.   cone {
  1153.     <0, 1, 0>, 0.3    // Center and radius of one end
  1154.     <1, 2, 3>, 1.0    // Center and radius of other end
  1155.     texture { T_Stone25 scale 4 }
  1156.   }
  1157. The cone shape is defined by the center and radius of each end.
  1158. In this example one end is at location <0,1,0> and has a radius
  1159. of 0.3 while the other end is centered at <1,2,3> with a radius
  1160. of 1. If we want the cone to come to a sharp point we must use
  1161. radius=0. The solid end caps are parallel to each other and
  1162. perpendicular to the cone axis. If we want an open cone with no
  1163. end caps we have to add the keyword open after the 2nd radius
  1164. like this:
  1165.  
  1166.   cone {
  1167.     <0, 1, 0>, 0.3    // Center and radius of one end
  1168.     <1, 2, 3>, 1.0    // Center and radius of other end
  1169.     open              // Removes end caps
  1170.     texture { T_Stone25 scale 4 }
  1171.   }
  1172.  
  1173. 2.2.3     Cylinder Object
  1174. We may also define a cylinder like this:
  1175.  
  1176.   cylinder {
  1177.     <0, 1, 0>,     // Center of one end
  1178.     <1, 2, 3>,     // Center of other end
  1179.     0.5            // Radius
  1180.     open           // Remove end caps
  1181.     texture { T_Stone25 scale 4 }
  1182.   }
  1183.  
  1184. 2.2.4     Plane Object
  1185. Let's try out a computer graphics standard "The Checkered Floor".
  1186. We add the following object to the first version of the demo.pov
  1187. file, the one including the sphere.
  1188.  
  1189.   plane { <0, 1, 0>, -1
  1190.     pigment {
  1191.       checker color Red, color Blue
  1192.     }
  1193.   }
  1194. The object defined here is an infinite plane. The vector <0,1,0>
  1195. is the surface normal of the plane (i.e. if we were standing on
  1196. the surface, the normal points straight up). The number afterward
  1197. is the distance that the plane is displaced along the normal from
  1198. the origin -- in this case, the floor is placed at y=-1 so that
  1199. the sphere at y=1, radius=2, is resting on it.
  1200.  
  1201. We note that even though there is no texture statement there is
  1202. an implied texture here. We might find that continually typing
  1203. statements that are nested like texture {pigment} can get to be
  1204. tiresome so POV-Ray let's us leave out the texture statement
  1205. under many circumstances. In general we only need the texture
  1206. block surrounding a texture identifier (like the T_Stone25
  1207. example above), or when creating layered textures (which are
  1208. covered later).
  1209.  
  1210. This pigment uses the checker color pattern and specifies that
  1211. the two colors red and blue should be used.
  1212.  
  1213. Because the vectors <1,0,0>, <0,1,0> and <0,0,1> are used
  1214. frequently, POV-Ray has three built-in vector identifiers x, y
  1215. and z respectively that can be used as a shorthand. Thus the
  1216. plane could be defined as:
  1217.  
  1218.   plane { y, -1
  1219.     pigment { ... }
  1220.   }
  1221. Note that we do not use angle brackets around vector identifiers.
  1222.  
  1223. Looking at the floor, we notice that the ball casts a shadow on
  1224. the floor. Shadows are calculated very accurately by the ray-
  1225. tracer, which creates precise, sharp shadows. In the real world,
  1226. penumbral or "soft" shadows are often seen. Later we will learn
  1227. how to use extended light sources to soften the shadows.
  1228.  
  1229.  
  1230. 2.3  CSG Objects
  1231. Constructive Solid Geometry, or CSG, is a powerful tool to
  1232. combine primitive objects to create more complex objects as shown
  1233. in the following sections.
  1234.  
  1235.  
  1236. 2.3.1     What is CSG?
  1237. CSG stands for Constructive Solid Geometry. POV-Ray allows us to
  1238. construct complex solids by combining primitive shapes in four
  1239. different ways. In the union statement, two or more shapes are
  1240. added together. With the intersection statement, two or more
  1241. shapes are combined to make a new shape that consists of the area
  1242. common to both shapes. The difference statement, an initial shape
  1243. has all subsequent shapes subtracted from it. And last not least
  1244. merge, which is like a union where the surfaces inside the union
  1245. are removed (useful in transparent CSG objects). We will deal
  1246. with each of these in detail in the next few sections.
  1247.  
  1248. CSG objects can be extremely complex. They can be deeply nested.
  1249. In other words there can be unions of differences or
  1250. intersections of merges or differences of intersections or even
  1251. unions of intersections of differences of merges... ad infinitum.
  1252. CSG objects are (almost always) finite objects and thus respond
  1253. to auto-bounding and can be transformed like any other POV
  1254. primitive shape.
  1255.  
  1256.  
  1257. 2.3.2     CSG Union
  1258. Let's try making a simple union. Create a file called csgdemo.pov
  1259. and edit it as follows:
  1260.  
  1261.   #include "colors.inc"
  1262.   camera {
  1263.     location <0, 1, -10>
  1264.     look_at 0
  1265.     angle 36
  1266.   }
  1267.   light_source { <500, 500, -1000> White }
  1268.   plane { y, -1.5
  1269.     pigment { checker Green White }
  1270.   }
  1271. Let's add two spheres each translated 0.5 units along the x-axis
  1272. in each direction. We color one blue and the other red.
  1273.  
  1274.   sphere { <0, 0, 0>, 1
  1275.     pigment { Blue }
  1276.     translate -0.5*x
  1277.   }
  1278.   sphere { <0, 0, 0>, 1
  1279.     pigment { Red }
  1280.     translate 0.5*x
  1281.   }
  1282. We trace this file and note the results. Now we place a union
  1283. block around the two spheres. This will create a single CSG union
  1284. out of the two objects.
  1285.  
  1286.   union{
  1287.     sphere { <0, 0, 0>, 1
  1288.       pigment { Blue }
  1289.       translate -0.5*x
  1290.     }
  1291.     sphere { <0, 0, 0>, 1
  1292.       pigment { Red }
  1293.       translate 0.5*x
  1294.     }
  1295.   }
  1296. We trace the file again. The union will appear no different from
  1297. what each sphere looked like on its own, but now we can give the
  1298. entire union a single texture and transform it as a whole. Let's
  1299. do that now.
  1300.  
  1301.   union{
  1302.     sphere { <0, 0, 0>, 1
  1303.       translate -0.5*x
  1304.     }
  1305.     sphere { <0, 0, 0>, 1
  1306.       translate 0.5*x
  1307.     }
  1308.     pigment { Red }
  1309.     scale <1, .25, 1>
  1310.     rotate <30, 0, 45>
  1311.   }
  1312. We trace the file again. As we can see, the object has changed
  1313. dramatically. We experiment with different values of scale and
  1314. rotate and try some different textures.
  1315.  
  1316. There are many advantages of assigning only one texture to a CSG
  1317. object instead of assigning the texture to each individual
  1318. component. First, it is much easier to use one texture if our CSG
  1319. object has a lot of components because changing the objects
  1320. appearance involves changing only one single texture. Second, the
  1321. file parses faster because the texture has to be parsed only
  1322. once. This may be a great factor when doing large scenes or
  1323. animations. Third, using only one texture saves memory because
  1324. the texture is only stored once and referenced by all components
  1325. of the CSG object. Assigning the texture to all n components
  1326. means that it is stored n times.
  1327.  
  1328.  
  1329. 2.3.3     CSG Intersection
  1330. Now let's use these same spheres to illustrate the next kind of
  1331. CSG object, the intersection. We change the word union to
  1332. intersection and delete the scale and rotate statements:
  1333.  
  1334.   intersection {
  1335.     sphere { <0, 0, 0>, 1
  1336.       translate -0.5*x
  1337.     }
  1338.     sphere { <0, 0, 0>, 1
  1339.       translate 0.5*x
  1340.     }
  1341.     pigment { Red }
  1342.   }
  1343. We trace the file and will see a lens-shaped object instead of
  1344. the two spheres. This is because an intersection consists of the
  1345. area shared by both shapes, in this case the lens-shaped area
  1346. where the two spheres overlap. We like this lens-shaped object so
  1347. we will use it to demonstrate differences.
  1348.  
  1349.  
  1350. 2.3.4     CSG Difference
  1351. We rotate the lens-shaped intersection about the y-axis so that
  1352. the broad side is facing the camera.
  1353.  
  1354.   intersection{
  1355.     sphere { <0, 0, 0>, 1
  1356.       translate -0.5*x
  1357.     }
  1358.     sphere { <0, 0, 0>, 1
  1359.       translate 0.5*x
  1360.     }
  1361.     pigment { Red }
  1362.     rotate 90*y
  1363.   }
  1364. Let's create a cylinder and stick it right in the middle of the
  1365. lens.
  1366.  
  1367.   cylinder { <0, 0, -1> <0, 0, 1>, .35
  1368.     pigment { Blue }
  1369.   }
  1370. We render the scene to see the position of the cylinder. We will
  1371. place a difference block around both the lens-shaped intersection
  1372. and the cylinder like this:
  1373.  
  1374.   difference {
  1375.     intersection {
  1376.       sphere { <0, 0, 0>, 1
  1377.         translate -0.5*x
  1378.       }
  1379.       sphere { <0, 0, 0>, 1
  1380.         translate 0.5*x
  1381.       }
  1382.       pigment { Red }
  1383.       rotate 90*y
  1384.     }
  1385.     cylinder { <0, 0, -1> <0, 0, 1>, .35
  1386.       pigment { Blue }
  1387.     }
  1388.   }
  1389. We render the file again and see the lens-shaped intersection
  1390. with a neat hole in the middle of it where the cylinder was. The
  1391. cylinder has been subtracted from the intersection. Note that the
  1392. pigment of the cylinder causes the surface of the hole to be
  1393. colored blue. If we eliminate this pigment the surface of the
  1394. hole will be red.
  1395.  
  1396. OK, let's get a little wilder now. Let's declare our perforated
  1397. lens object to give it a name. Let's also eliminate all textures
  1398. in the declared object because we will want them to be in the
  1399. final union instead.
  1400.  
  1401.   #declare Lens_With_Hole = difference {
  1402.     intersection {
  1403.       sphere { <0, 0, 0>, 1
  1404.         translate -0.5*x
  1405.       }
  1406.       sphere { <0, 0, 0>, 1
  1407.         translate 0.5*x
  1408.       }
  1409.       rotate 90*y
  1410.     }
  1411.     cylinder { <0, 0, -1> <0, 0, 1>, .35 }
  1412.   }
  1413. Let's use a union to build a complex shape composed of copies of
  1414. this object.
  1415.  
  1416.   union {
  1417.     object { Lens_With_Hole translate <-.65, .65, 0> }
  1418.     object { Lens_With_Hole translate <.65, .65, 0> }
  1419.     object { Lens_With_Hole translate <-.65, -.65, 0> }
  1420.     object { Lens_With_Hole translate <.65, -.65, 0> }
  1421.     pigment { Red }
  1422.   }
  1423. We render the scene. An interesting object to be sure. But let's
  1424. try something more. Let's make it a partially-transparent object
  1425. by adding some filter to the pigment block.
  1426.  
  1427.   union {
  1428.     object { Lens_With_Hole translate <-.65, .65, 0> }
  1429.     object { Lens_With_Hole translate <.65, .65, 0> }
  1430.     object { Lens_With_Hole translate <-.65, -.65, 0> }
  1431.     object { Lens_With_Hole translate <.65, -.65, 0> }
  1432.     pigment { Red filter .5 }
  1433.   }
  1434. We render the file again. This looks pretty good... only... we
  1435. can see parts of each of the lens objects inside the union! This
  1436. is not good.
  1437.  
  1438.  
  1439. 2.3.5     CSG Merge
  1440. This brings us to the fourth kind of CSG object, the merge.
  1441. Merges are the same as unions, but the geometry of the objects in
  1442. the CSG that is inside the merge is not traced. This should
  1443. eliminate the problem with our object. Let's try it.
  1444.  
  1445.   merge {
  1446.     object { Lens_With_Hole translate <-.65, .65, 0> }
  1447.     object { Lens_With_Hole translate <.65, .65, 0> }
  1448.     object { Lens_With_Hole translate <-.65, -.65, 0> }
  1449.     object { Lens_With_Hole translate <.65, -.65, 0> }
  1450.     pigment { Red filter .5 }
  1451.   }
  1452. Sure enough, it does!
  1453.  
  1454.  
  1455. 2.3.6     CSG Pitfalls
  1456. There is a severe pitfall in the CSG code that we have to be
  1457. aware of.
  1458.  
  1459.  
  1460. 2.3.6.1   Coincidence Surfaces
  1461. POV-Ray uses inside/outside tests to determine the points at
  1462. which a ray intersects a CSG object. A problem arises when the
  1463. surfaces of two different shapes coincide because there is no way
  1464. (due to numerical problems) to tell whether a point on the
  1465. coincident surface belongs to one shape or the other.
  1466.  
  1467. Look at the following example where a cylinder is used to cut a
  1468. hole in a larger box.
  1469.  
  1470.   difference {
  1471.     box { -1, 1 pigment { Red } }
  1472.     cylinder { -z, z, 0.5 pigment { Green } }
  1473.   }
  1474. Note that the vectors -1 and 1 in the box definition expand to <-
  1475. 1,-1,-1> and <1,1,1> respectively.
  1476.  
  1477. If we trace this object we see red speckles where the hole is
  1478. supposed to be. This is caused by the coincident surfaces of the
  1479. cylinder and the box. One time the cylinder's surface is hit
  1480. first by a viewing ray, resulting in the correct rendering of the
  1481. hole, and another time the box is hit first, leading to a wrong
  1482. result where the hole vanishes and red speckles appear.
  1483.  
  1484. This problem can be avoided by increasing the size of the
  1485. cylinder to get rid of the coincidence surfaces. This is done by:
  1486.  
  1487.   difference {
  1488.     box { -1, 1 pigment { Red } }
  1489.     cylinder { -1.001*z, 1.001*z, 0.5 pigment { Green } }
  1490.   }
  1491. In general we have to make the subtracted object a little bit
  1492. larger in a CSG difference. We just have to look for coincident
  1493. surfaces and increase the subtracted object appropriately to get
  1494. rid of those surfaces.
  1495.  
  1496. The same problem occurs in CSG intersections and is also avoided
  1497. by scaling some of the involved objects.
  1498.  
  1499.  
  1500. 2.4  Advanced Shapes
  1501. After we have gained some experience with the simpler shapes
  1502. available in POV-Ray it is time to go on to the more advanced,
  1503. thrilling shapes.
  1504.  
  1505. We should be aware that the shapes described below are not
  1506. trivial to understand. We needn't be worried though if we do not
  1507. know how to use them or how they work. We just try the examples
  1508. and play with the features described in the reference chapter.
  1509. There is nothing better than learning by doing.
  1510.  
  1511. You may wish to skip to the chapter "Simple Texture Options"
  1512. before proceeding with these advanced shapes.
  1513.  
  1514.  
  1515. 2.4.1     Bicubic Patch Object
  1516. Bicubic or Bezier patches are useful surface representations
  1517. because they allow an easy definition of surfaces using only a
  1518. few control points. The control points serve to determine the
  1519. shape of the patch. Instead of defining the vertices of
  1520. triangles, we simply give the coordinates of the control points.
  1521. A single patch has 16 control points, one at each corner, and the
  1522. rest positioned to divide the patch into smaller sections. For
  1523. ray-tracing (or rendering) the patches are approximated using
  1524. triangles.
  1525.  
  1526. Bezier patches are almost always created using a third party
  1527. modeler so for this tutorial, we will use moray (any other
  1528. modeler that supports Bezier patches and POV-Ray can also be
  1529. used).  We will use moray only to create the patch itself, not
  1530. the other elements of the scene.
  1531.  
  1532. Note that moray is not included with POV-Ray.  It is a separate
  1533. shareware program that currently only runs on MS-Dos and Win95/NT
  1534. but this tutorial assumes you are using the MS-Dos version.  If
  1535. you do not have moray or are not on MS-Dos, you can still render
  1536. the sample scene described below, even though you cannot see how
  1537. moray created it. Simply type in the bicubic_patch declaration
  1538. listed below.
  1539.  
  1540. Bezier patches are actually very useful and, with a little
  1541. practice, some pretty amazing things can be created with them.
  1542. For our first tutorial, let's make a sort of a teepee/tent shape
  1543. using a single sheet patch.
  1544.  
  1545. First, we start moray and, from the main edit screen, we click on
  1546. "CREATE". We Name our object Teepee. The "CREATE BEZIER PATCH"
  1547. dialogue box will appear. We have to make sure that "SHEET" is
  1548. depressed. We click on "OK, CREATE". At the bottom of the main
  1549. edit screen, we click on "EXTENDED EDIT".
  1550.  
  1551. We hold the cursor over the "TOP" view and right click to make
  1552. the pop-up menu appear. We click on "MAXIMIZE". We [ALT]-drag to
  1553. zoom in a little. We click on "MARK ALL", and under the
  1554. transformation mode box, "UFRM SCL". We drag the mouse to scale
  1555. the patch until it is approximately four units wide. We click on
  1556. "TRANSLATE", and move the patch so that its center is over the
  1557. origin. We right click "MINIMIZE" and "UNMARK ALL".
  1558.  
  1559. We [SHIFT]-drag a box around the lower right control point to
  1560. mark it. We [ALT]-zoom into the "FRONT" view so that we can see
  1561. the patch better.  In the "FRONT" view, we "TRANSLATE" that point
  1562. 10 units along the negative z-axis (we note that in MORAY z is
  1563. up). We "UNMARK ALL". We repeat this procedure for each of the
  1564. other three corner points. We make sure we remember to "UNMARK
  1565. ALL" once each point has been translated. We should have a shape
  1566. that looks as though it is standing on four pointed legs. We
  1567. "UNMARK ALL".
  1568.  
  1569. Working once again in the "TOP" view, we [SHIFT]-drag a box
  1570. around the four center control points to mark them. We right-
  1571. click over the "TOP" view and "MAXIMIZE". We click on "UFRM SCL"
  1572. and drag the mouse to scale the four points close together. We
  1573. [ALT]-drag to zoom closer and get them as close together as we
  1574. can. We [ALT]-drag to zoom out, right click and "MINIMIZE".
  1575.  
  1576. In the "FRONT" view, we "TRANSLATE" the marked points 10 units
  1577. along the positive z-axis. We "UNMARK ALL". The resulting shape
  1578. is quite interesting, was simple to model, and could not be
  1579. produced using CSG primitives. Now let's use it in a scene.
  1580.  
  1581. We click on "DONE" to return to the main edit screen. We note
  1582. that u_steps and v_steps are both set to 3 and flatness is set to
  1583. 0.01. We leave them alone for now. We click on "FILES" and then
  1584. "SAVE SEL" (save selection). We name our new file teepee1.mdl. We
  1585. press [F3] and open teepee1.mdl. There is no need to save the
  1586. original file. When teepee1 is open, we create a quick "dummy"
  1587. texture (moray will not allow us to export data without a
  1588. texture). We use white with default finish and name it TeePeeTex.
  1589. We apply it to the object, save the file and press [CTRL-F9].
  1590. moray will create two files: teepee1.inc and teepee1.pov.
  1591.  
  1592. We exit moray and copy teepee1.inc and teepee1.pov into our
  1593. working directory where we are doing these tutorials.  We create
  1594. a new file called bezdemo.pov and edit it as follows:
  1595.  
  1596.   #include "colors.inc"
  1597.   camera {
  1598.     location <0, .1, -60>
  1599.     look_at 0
  1600.     angle 40
  1601.   }
  1602.   background { color Gray25 }  //to make the patch easier to see
  1603.   light_source { <300, 300, -700> White }
  1604.   plane { y, -12
  1605.     texture {
  1606.       pigment {
  1607.         checker
  1608.         color Green
  1609.         color Yellow
  1610.       }
  1611.     }
  1612.   }
  1613. Using a text editor, we create and declare a simple texture for
  1614. our teepee object:
  1615.  
  1616.   #declare TeePeeTex = texture {
  1617.     pigment {
  1618.       color rgb <1, 1, 1,>
  1619.     }
  1620.     finish {
  1621.       ambient .2
  1622.       diffuse .6
  1623.     }
  1624.   }
  1625. We paste in the bezier patch data from teepee1.pov (the
  1626. additional object keywords added by moray were removed):
  1627.  
  1628.   bicubic_patch {
  1629.     type 1 flatness 0.0100 u_steps 3 v_steps 3,
  1630.     <-5.174134, 5.528420, -13.211995>,
  1631.     <-1.769023, 5.528420, 0.000000>,
  1632.     <1.636088, 5.528420, 0.000000>,
  1633.     <5.041199, 5.528420, -13.003932>,
  1634.     <-5.174134, 1.862827, 0.000000>,
  1635.     <0.038471, 0.031270, 18.101474>,
  1636.     <0.036657, 0.031270, 18.101474>,
  1637.     <5.041199, 1.862827, 0.000000>,
  1638.     <-5.174134, -1.802766, 0.000000>,
  1639.     <0.038471, 0.028792, 18.101474>,
  1640.     <0.036657, 0.028792, 18.101474>,
  1641.     <5.041199, -1.802766, 0.000000>,
  1642.     <-5.174134, -5.468359, -13.070366>,
  1643.     <-1.769023, -5.468359, 0.000000>,
  1644.     <1.636088, -5.468359, 0.000000>,
  1645.     <4.974128, -5.468359, -12.801446>
  1646.     texture {
  1647.       TeePeeTex
  1648.     }
  1649.     rotate -90*x  // to orient the object to LHC
  1650.     rotate 25*y   // to see the four "legs" better
  1651.   }
  1652. We add the above rotations so that the patch is oriented to POV-
  1653. Ray's left-handed coordinate system (remember the patch was made
  1654. in moray in a right handed coordinate system), so we can see all
  1655. four legs. Rendering this at 200x150 -a we see pretty much what
  1656. we expect, a white teepee over a green and yellow checkered
  1657. plane. Let's take a little closer look. We render it again, this
  1658. time at 320x200.
  1659.  
  1660. Now we see that something is amiss. There appears to be sharp
  1661. angling, almost like facing, especially near the top. This is
  1662. indeed a kind of facing and is due to the u_steps and v_steps
  1663. parameters. Let's change these from 3 to 4 and see what happens.
  1664.  
  1665. That's much better, but it took a little longer to render. This
  1666. is an unavoidable tradeoff. If we want even finer detail, we must
  1667. use a u_steps and v_steps value of 5 and set flatness to 0. But
  1668. we must expect to use lots of memory and an even longer tracing
  1669. time.
  1670.  
  1671. Well, we can't just leave this scene without adding a few items
  1672. just for interest. We declare the patch object and scatter a few
  1673. of them around the scene:
  1674.  
  1675.   #declare TeePee = bicubic_patch {
  1676.     type 1 flatness 0.0100 u_steps 3 v_steps 3,
  1677.     <-5.174134, 5.528420, -13.211995>,
  1678.     <-1.769023, 5.528420, 0.000000>,
  1679.     <1.636088, 5.528420, 0.000000>,
  1680.     <5.041199, 5.528420, -13.003932>,
  1681.     <-5.174134, 1.862827, 0.000000>,
  1682.     <0.038471, 0.031270, 18.101474>,
  1683.     <0.036657, 0.031270, 18.101474>,
  1684.     <5.041199, 1.862827, 0.000000>,
  1685.     <-5.174134, -1.802766, 0.000000>,
  1686.     <0.038471, 0.028792, 18.101474>,
  1687.     <0.036657, 0.028792, 18.101474>,
  1688.     <5.041199, -1.802766, 0.000000>,
  1689.     <-5.174134, -5.468359, -13.070366>,
  1690.     <-1.769023, -5.468359, 0.000000>,
  1691.     <1.636088, -5.468359, 0.000000>,
  1692.     <4.974128, -5.468359, -12.801446>
  1693.     texture {
  1694.       TeePeeTex
  1695.      }
  1696.      rotate -90*x // to orient the object to LHC
  1697.      rotate 25*y  // to see the four "legs" better
  1698.   }
  1699.   object { TeePee }
  1700.   object { TeePee translate <8, 0, 8> }
  1701.   object { TeePee translate <-9, 0, 9> }
  1702.   object { TeePee translate <18, 0, 24> }
  1703.   object { TeePee translate <-18, 0, 24> }
  1704. That looks good. Let's do something about that boring gray
  1705. background. We delete the background declaration and replace it
  1706. with:
  1707.  
  1708.   plane { y, 500
  1709.     texture {
  1710.       pigment { SkyBlue }
  1711.       finish { ambient 1 diffuse 0}
  1712.      }
  1713.      texture {
  1714.        pigment {
  1715.          bozo
  1716.          turbulence .5
  1717.          color_map {
  1718.            [0 White]
  1719.            [1 White filter 1]
  1720.          }
  1721.        }
  1722.        finish { ambient 1 diffuse 0 }
  1723.        scale <1000, 250, 250>
  1724.        rotate <5, 45, 0>
  1725.     }
  1726.   }
  1727. This adds a pleasing cirrus-cloud filled sky. Now, let's change
  1728. the checkered plane to rippled sand dunes:
  1729.  
  1730.   plane {y,-12
  1731.     texture {
  1732.       pigment {
  1733.         color <.85, .5, .15>
  1734.       }
  1735.       finish {
  1736.         ambient .25
  1737.         diffuse .6
  1738.         crand .5
  1739.       }
  1740.       normal {
  1741.         ripples .35
  1742.         turbulence .25
  1743.         frequency 5
  1744.       }
  1745.       scale 10
  1746.       translate 50*x
  1747.     }
  1748.   }
  1749. We render this. Not bad! Let's just add one more element.  Let's
  1750. place a golden egg under each of the teepees. And since this is a
  1751. bezier patch tutorial, let's make the eggs out of bezier patches.
  1752.  
  1753. We return to moray and create another bezier patch. We name it
  1754. Egg1 and select "CYLINDRICAL 2 - PATCH" from the "CREATE BEZIER
  1755. PATCH" dialogue box. We click on "EXTENDED EDIT". We "MARK ALL"
  1756. and rotate the patch so that the cylinder lays on its side. We
  1757. "UNMARK ALL". In the "FRONT" view, we [SHIFT]-drag a box around
  1758. the four points on the right end to mark them. In the "SIDE"
  1759. view, we right click and "MAXIMIZE".  We [ALT]-drag to zoom in a
  1760. little closer. We "UFRM SCL" the points together as close as
  1761. possible. We zoom in closer to get them nice and tight. We zoom
  1762. out, right click and "MINIMIZE".
  1763.  
  1764. We click on "TRANSLATE" and drag the points to the left so that
  1765. they are aligned on the z-axis with the next group of four
  1766. points. This should create a blunt end to the patch. We repeat
  1767. this procedure for the other end. We "UNMARK ALL".
  1768.  
  1769. In the "FRONT" view, the control grid should be a rectangle now
  1770. and the patch should be an ellipsoid. We [SHIFT]-drag a box
  1771. around the upper right corner of the control grid to mark those
  1772. points. We then [SHIFT]-drag a box around the lower right corner
  1773. to mark those points as well. In the "SIDE" view, we "UFRM SCL"
  1774. the points apart a little to make that end of the egg a little
  1775. wider than the other. We "UNMARK ALL".
  1776.  
  1777. The egg may need a little proportional adjustment. We should be
  1778. able to "MARK ALL" and "LOCAL SCL" in the three views until we
  1779. get it to look like an egg. When we are satisfied that it does,
  1780. we "UNMARK ALL" and click on done. Learning from our teepee
  1781. object, we now go ahead and change u_steps and v_steps to 4.
  1782.  
  1783. We create a dummy texture, white with default finish, name it
  1784. EggTex and apply it to the egg. From the FILES menu, we "SAVE
  1785. SEL" to filename egg1.mdl. We load this file and export ([CTRL
  1786. F9]). We exit moray and copy the files egg1.inc and egg1.pov into
  1787. our working directory.
  1788.  
  1789. Back in bezdemo.pov, we create a nice, shiny gold texture:
  1790.  
  1791.   #declare EggTex = texture {
  1792.     pigment { BrightGold }
  1793.     finish {
  1794.       ambient .1
  1795.       diffuse .4
  1796.       specular 1
  1797.       roughness 0.001
  1798.       reflection .5
  1799.       metallic
  1800.     }
  1801.   }
  1802. And while we're at it, let's dandy up our TeePeeTex texture:
  1803.  
  1804.   #declare TeePeeTex = texture {
  1805.     pigment { Silver }
  1806.     finish {
  1807.       ambient .1
  1808.       diffuse .4
  1809.       specular 1
  1810.       roughness 0.001
  1811.       reflection .5
  1812.       metallic
  1813.     }
  1814.   }
  1815. Now we paste in our egg patch data and declare our egg:
  1816.  
  1817.   #declare Egg = union { // Egg1
  1818.     bicubic_patch {
  1819.       type 1 flatness 0.0100 u_steps 4 v_steps 4,
  1820.       <2.023314, 0.000000, 4.355987>,
  1821.       <2.023314, -0.000726, 4.355987>,
  1822.       <2.023312, -0.000726, 4.356867>,
  1823.       <2.023312, 0.000000, 4.356867>,
  1824.       <2.032037, 0.000000, 2.734598>,
  1825.       <2.032037, -1.758562, 2.734598>,
  1826.       <2.027431, -1.758562, 6.141971>,
  1827.       <2.027431, 0.000000, 6.141971>,
  1828.       <-1.045672, 0.000000, 3.281572>,
  1829.       <-1.045672, -1.758562, 3.281572>,
  1830.       <-1.050279, -1.758562, 5.414183>,
  1831.       <-1.050279, 0.000000, 5.414183>,
  1832.       <-1.044333, 0.000000, 4.341816>,
  1833.       <-1.044333, -0.002947, 4.341816>,
  1834.       <-1.044341, -0.002947, 4.345389>,
  1835.       <-1.044341, 0.000000, 4.345389>
  1836.     }
  1837.     bicubic_patch {
  1838.       type 1 flatness 0.0100 u_steps 4 v_steps 4,
  1839.       <2.023312, 0.000000, 4.356867>,
  1840.       <2.023312, 0.000726, 4.356867>,
  1841.       <2.023314, 0.000726, 4.355987>,
  1842.       <2.023314, 0.000000, 4.355987>,
  1843.       <2.027431, 0.000000, 6.141971>,
  1844.       <2.027431, 1.758562, 6.141971>,
  1845.       <2.032037, 1.758562, 2.734598>,
  1846.       <2.032037, 0.000000, 2.734598>,
  1847.       <-1.050279, 0.000000, 5.414183>,
  1848.       <-1.050279, 1.758562, 5.414183>,
  1849.       <-1.045672, 1.758562, 3.281572>,
  1850.       <-1.045672, 0.000000, 3.281572>,
  1851.       <-1.044341, 0.000000, 4.345389>,
  1852.       <-1.044341, 0.002947, 4.345389>,
  1853.       <-1.044333, 0.002947, 4.341816>,
  1854.       <-1.044333, 0.000000, 4.341816>
  1855.     }
  1856.     texture { EggTex }
  1857.     translate <0.5, 0, -5>  // centers the egg around the origin
  1858.     translate -9.8*y        // places the egg on the ground
  1859.   }
  1860. We now place a copy of the egg under each teepee. This should
  1861. require only the x- and z-coordinates of each teepee to be
  1862. changed:
  1863.  
  1864.   object { Egg }
  1865.   object { Egg translate <8, 0, 8> }
  1866.   object { Egg translate <-9, 0, 9> }
  1867.   object { Egg translate <18, 0, 24> }
  1868.   object { Egg translate <-18, 0, 24> }
  1869.                                 
  1870.            Scene build with different Bezier patches.
  1871. We render this at low resolution such as 320x240. Everything
  1872. looks good so we run it again at 640x480.  Now we see that there
  1873. is still some facing near the top of the teepees and on the eggs
  1874. as well. The only solution is to raise u_steps and v_steps from 4
  1875. to 5 and set flatness to 0 for all our bezier objects. We make
  1876. the changes and render it again at 640x480.  The facets are gone.
  1877.  
  1878.  
  1879. 2.4.2     Blob Object
  1880. Blobs are described as spheres and cylinders covered with "goo"
  1881. which stretches to smoothly join them (see section "Blob"). Ideal
  1882. for modeling atoms and molecules, blobs are also powerful tools
  1883. for creating many smooth flowing "organic" shapes.
  1884.  
  1885. A slightly more mathematical way of describing a blob would be to
  1886. say that it is one object made up of two or more component
  1887. pieces. Each piece is really an invisible field of force which
  1888. starts out at a particular strength and falls off smoothly to
  1889. zero at a given radius. Where ever these components overlap in
  1890. space, their field strength gets added together (and yes, we can
  1891. have negative strength which gets subtracted out of the total as
  1892. well). We could have just one component in a blob, but except for
  1893. seeing what it looks like there is little point, since the real
  1894. beauty of blobs is the way the components interact with one
  1895. another.
  1896.  
  1897. Let us take a simple example blob to start. Now, in fact there
  1898. are a couple different types of components but we will look at
  1899. them a little later. For the sake of a simple first example, let
  1900. us just talk about spherical components. Here is a sample POV-Ray
  1901. code showing a basic camera, light, and a simple two component
  1902. blob (this scene is called blobdem1.pov):
  1903.  
  1904.   #include "colors.inc"
  1905.   background{White}
  1906.   camera {
  1907.     angle 15
  1908.     location <0,2,-10>
  1909.     look_at <0,0,0>
  1910.   }
  1911.   light_source { <10, 20, -10> color White }
  1912.   blob {
  1913.     threshold .65
  1914.     sphere { <.5,0,0>, .8, 1 pigment {Blue} }
  1915.     sphere { <-.5,0,0>,.8, 1 pigment {Pink} }
  1916.     finish { phong 1 }
  1917.   }
  1918.                                 
  1919.                     A simple, two-part blob.
  1920. The threshold is simply the overall strength value at which the
  1921. blob becomes visible. Any points within the blob where the
  1922. strength matches the threshold exactly form the surface of the
  1923. blob shape. Those less than the threshold are outside and those
  1924. greater than are inside the blob.
  1925.  
  1926. We note that the spherical component looks a lot like a simple
  1927. sphere object. We have the sphere keyword, the vector
  1928. representing the location of the center of the sphere and the
  1929. float representing the radius of the sphere. But what is that
  1930. last float value? That is the individual strength of that
  1931. component. In a spherical component, that is how strong the
  1932. component's field is at the center of the sphere. It will fall
  1933. off in a linear progression until it reaches exactly zero at the
  1934. radius of the sphere.
  1935.  
  1936. Before we render this test image, we note that we have given each
  1937. component a different pigment. POV-Ray allows blob components to
  1938. be given separate textures. We have done this here to make it
  1939. clearer which parts of the blob are which. We can also texture
  1940. the whole blob as one, like the finish statement at the end,
  1941. which applies to all components since it appears at the end,
  1942. outside of all the components. We render the scene and get a
  1943. basic kissing spheres type blob.
  1944.  
  1945. The image we see shows the spheres on either side, but they are
  1946. smoothly joined by that bridge section in the center. This bridge
  1947. represents where the two fields overlap, and therefore stay above
  1948. the threshold for longer than elsewhere in the blob. If that is
  1949. not totally clear, we add the following two objects to our scene
  1950. and re-render (see file blobdem2.pov). We note that these are
  1951. meant to be entered as separate sphere objects, not more
  1952. components in the blob.
  1953.  
  1954.   sphere { <.5,0,0>, .8
  1955.     pigment { Yellow transmit .75 }
  1956.   }
  1957.   sphere { <-.5,0,0>, .8
  1958.     pigment { Green transmit .75 }
  1959.   }
  1960.                                 
  1961.              The spherical components made visible.
  1962. Now the secrets of the kissing spheres are laid bare. These semi-
  1963. transparent spheres show where the components of the blob
  1964. actually are. If we have not worked with blobs before, we might
  1965. be surprised to see that the spheres we just added extend way
  1966. farther out than the spheres that actually show up on the blobs.
  1967. That of course is because our spheres have been assigned a
  1968. starting strength of one, which gradually fades to zero as we
  1969. move away from the sphere's center. When the strength drops below
  1970. the threshold (in this case 0.65) the rest of the sphere becomes
  1971. part of the outside of the blob and therefore is not visible.
  1972.  
  1973. See the part where the two transparent spheres overlap? We note
  1974. that it exactly corresponds to the bridge between the two
  1975. spheres. That is the region where the two components are both
  1976. contributing to the overall strength of the blob at that point.
  1977. That is why the bridge appears: that region has a high enough
  1978. strength to stay over the threshold, due to the fact that the
  1979. combined strength of two spherical components is overlapping
  1980. there.
  1981.  
  1982.  
  1983. 2.4.2.1   Component Types and Other New Features
  1984. The shape shown so far is interesting, but limited. POV-Ray has a
  1985. few extra tricks that extend its range of usefulness however. For
  1986. example, as we have seen, we can assign individual textures to
  1987. blob components, we can also apply individual transformations
  1988. (translate, rotate and scale) to stretch, twist, and squash
  1989. pieces of the blob as we require. And perhaps most interestingly,
  1990. the blob code has been extended to allow cylindrical components.
  1991.  
  1992. Before we move on to cylinders, it should perhaps be mentioned
  1993. that the old style of components used in previous versions of POV-
  1994. Ray still work. Back then, all components were spheres, so it was
  1995. not necessary to say sphere or cylinder. An old style component
  1996. had the form:
  1997.  
  1998.   component Strength, Radius, <Center>
  1999. This has the same effect as a spherical component, just as we
  2000. already saw above. This is only useful for backwards
  2001. compatibility. If we already have POV-Ray files with blobs from
  2002. earlier versions, this is when we would need to recognize these
  2003. components. We note that the old style components did not put
  2004. braces around the strength, radius and center, and of course, we
  2005. cannot independently transform or texture them.  Therefore if we
  2006. are modifying an older work into a new version, it may arguably
  2007. be of benefit to convert old style components into spherical
  2008. components anyway.
  2009.  
  2010. Now for something new and different: cylindrical components. It
  2011. could be argued that all we ever needed to do to make a roughly
  2012. cylindrical portion of a blob was string a line of spherical
  2013. components together along a straight line. Which is fine, if we
  2014. like having extra to type, and also assuming that the cylinder
  2015. was oriented along an axis.  If not, we would have to work out
  2016. the mathematical position of each component to keep it is a
  2017. straight line. But no more! Cylindrical components have arrived.
  2018.  
  2019. We replace the blob in our last example with the following and re-
  2020. render. We can get rid of the transparent spheres too, by the
  2021. way.
  2022.  
  2023.   blob {
  2024.     threshold .65
  2025.     cylinder { <-.75,-.75,0>, <.75,.75,0>, .5, 1 }
  2026.     pigment { Blue }
  2027.     finish { phong 1 }
  2028.   }
  2029. We only have one component so that we can see the basic shape of
  2030. the cylindrical component. It is not quite a true cylinder - more
  2031. of a sausage shape, being a cylinder capped by two hem-spheres.
  2032. We think of it as if it were an array of spherical components all
  2033. closely strung along a straight line.
  2034.  
  2035. As for the component declaration itself: simple, logical, exactly
  2036. as we would expect it to look (assuming we have been awake so
  2037. far): it looks pretty much like the declaration of a cylinder
  2038. object, with vectors specifying the two endpoints and a float
  2039. giving the radius of the cylinder. The last float, of course, is
  2040. the strength of the component. Just as with spherical components,
  2041. the strength will determine the nature and degree of this
  2042. component's interaction with its fellow components. In fact, next
  2043. let us give this fellow something to interact with, shall we?
  2044.  
  2045.  
  2046. 2.4.2.2   Complex Blob Constructs and Negative Strength
  2047. Beginning a new POV-Ray file called blobdem3.pov, we enter this
  2048. somewhat more complex example:
  2049.  
  2050.   #include "colors.inc"
  2051.   background{White}
  2052.   camera {
  2053.     angle 20
  2054.     location<0,2,-10>
  2055.     look_at<0,0,0>
  2056.   }
  2057.   light_source { <10, 20, -10> color White }
  2058.   blob {
  2059.     threshold .65
  2060.     sphere { <-.23,-.32,0>,.43, 1 scale <1.95,1.05,.8> }   //palm
  2061.     sphere { <+.12,-.41,0>,.43, 1 scale <1.95,1.075,.8> }  //palm
  2062.     sphere { <-.23,-.63,0>, .45, .75 scale <1.78, 1.3,1> }
  2063. //midhand
  2064.     sphere { <+.19,-.63,0>, .45, .75 scale <1.78, 1.3,1> }
  2065. //midhand
  2066.     sphere { <-.22,-.73,0>, .45, .85 scale <1.4, 1.25,1> } //heel
  2067.     sphere { <+.19,-.73,0>, .45, .85 scale <1.4, 1.25,1> } //heel
  2068.     cylinder { <-.65,-.28,0>, <-.65,.28,-.05>, .26, 1 }
  2069. //lower pinky
  2070.     cylinder { <-.65,.28,-.05>, <-.65, .68,-.2>, .26, 1 }
  2071. //upper pinky
  2072.     cylinder { <-.3,-.28,0>, <-.3,.44,-.05>, .26, 1 }
  2073. //lower ring
  2074.     cylinder { <-.3,.44,-.05>, <-.3, .9,-.2>, .26, 1 }
  2075. //upper ring
  2076.     cylinder { <.05,-.28,0>, <.05, .49,-.05>, .26, 1 }
  2077. //lower middle
  2078.     cylinder { <.05,.49,-.05>, <.05, .95,-.2>, .26, 1 }
  2079. //upper middle
  2080.     cylinder { <.4,-.4,0>, <.4, .512, -.05>, .26, 1 }
  2081. //lower index
  2082.     cylinder { <.4,.512,-.05>, <.4, .85, -.2>, .26, 1 }
  2083. //upper index
  2084.     cylinder { <.41, -.95,0>, <.85, -.68, -.05>, .25, 1 }
  2085. //lower thumb
  2086.     cylinder { <.85,-.68,-.05>, <1.2, -.4, -.2>, .25, 1 }
  2087. //upper thumb
  2088.     pigment { Flesh }
  2089.   }
  2090.                                 
  2091.                      A hand made with blobs.
  2092. As we can guess from the comments, we are building a hand here.
  2093. After we render this image, we can see there are a few problems
  2094. with it. The palm and heel of the hand would look more realistic
  2095. if we used a couple dozen smaller components rather than the half
  2096. dozen larger ones we have used, and each finger should have three
  2097. segments instead of two, but for the sake of a simplified
  2098. demonstration, we can overlook these points. But there is one
  2099. thing we really need to address here: This poor fellow appears to
  2100. have horrible painful swelling of the joints!
  2101.  
  2102. A review of what we know of blobs will quickly reveal what went
  2103. wrong. The joints are places where the blob components overlap,
  2104. therefore the combined strength of both components at that point
  2105. causes the surface to extend further out, since it stays over the
  2106. threshold longer. To fix this, what we need are components
  2107. corresponding to the overlap region which have a negative
  2108. strength to counteract part of the combined field strength. We
  2109. add the following components to our blob (see file blobdem4.pov).
  2110.  
  2111.   sphere { <-.65,.28,-.05>, .26, -1 } //counteract pinky knuckle
  2112. bulge
  2113.   sphere { <-.65,-.28,0>, .26, -1 }   //counteract pinky palm
  2114. bulge
  2115.   sphere { <-.3,.44,-.05>, .26, -1 }  //counteract ring knuckle
  2116. bulge
  2117.   sphere { <-.3,-.28,0>, .26, -1 }    //counteract ring palm
  2118. bulge
  2119.   sphere { <.05,.49,-.05>, .26, -1 }  //counteract middle knuckle
  2120. bulge
  2121.   sphere { <.05,-.28,0>, .26, -1 }    //counteract middle palm
  2122. bulge
  2123.   sphere { <.4,.512,-.05>, .26, -1 }  //counteract index knuckle
  2124. bulge
  2125.   sphere { <.4,-.4,0>, .26, -1 }      //counteract index palm
  2126. bulge
  2127.   sphere { <.85,-.68,-.05>, .25, -1 } //counteract thumb knuckle
  2128. bulge
  2129.   sphere { <.41,-.7,0>, .25, -.89 }   //counteract thumb heel
  2130. bulge
  2131.                                 
  2132.               The hand without the swollen joints.
  2133. Much better! The negative strength of the spherical components
  2134. counteracts approximately half of the field strength at the
  2135. points where to components overlap, so the ugly, unrealistic (and
  2136. painful looking) bulging is cut out making our hand considerably
  2137. improved. While we could probably make a yet more realistic hand
  2138. with a couple dozen additional components, what we get this time
  2139. is a considerable improvement. Any by now, we have enough basic
  2140. knowledge of blob mechanics to make a wide array of smooth,
  2141. flowing organic shapes!
  2142.  
  2143.  
  2144. 2.4.3     Height Field Object
  2145. A height_field is an object that has a surface that is determined
  2146. by the color value or palette index number of an image designed
  2147. for that purpose. With height fields, realistic mountains and
  2148. other types of terrain can easily be made. First, we need an
  2149. image from which to create the height field. It just so happens
  2150. that POV-Ray is ideal for creating such an image.
  2151.  
  2152. We make a new file called image.pov and edit it to contain the
  2153. following:
  2154.  
  2155.   #include "colors.inc"
  2156.   global_settings {
  2157.     assumed_gamma 2.2
  2158.     hf_gray_16
  2159.   }
  2160. The hf_gray_16 keyword causes the output to be in a special 16
  2161. bit grayscale that is perfect for generating height fields. The
  2162. normal 8 bit output will lead to less smooth surfaces.
  2163.  
  2164. Now we create a camera positioned so that it points directly down
  2165. the z-axis at the origin.
  2166.  
  2167.   camera {
  2168.     location <0, 0, -10>
  2169.     look_at 0
  2170.   }
  2171. We then create a plane positioned like a wall at z=0. This plane
  2172. will completely fill the screen. It will be colored with white
  2173. and gray wrinkles.
  2174.  
  2175.   plane { z, 10
  2176.     pigment {
  2177.       wrinkles
  2178.       color_map {
  2179.        [0 0.3*White]
  2180.        [1 White]
  2181.       }
  2182.     }
  2183.   }
  2184. Finally, create a light source.
  2185.  
  2186.   light_source { <0, 20, -100> color White }
  2187. We render this scene at 640x480 +A0.1 +FT. We will get an image
  2188. that will produce an excellent height field. We create a new file
  2189. called hfdemo.pov and edit it as follows:
  2190.  
  2191.   #include "colors.inc"
  2192. We add a camera that is two units above the origin and ten units
  2193. back ...
  2194.  
  2195.   camera{
  2196.     location <0, 2, -10>
  2197.     look_at 0
  2198.     angle 30
  2199.   }
  2200. ... and a light source.
  2201.  
  2202.   light_source{ <1000,1000,-1000> White }
  2203. Now we add the height field. In the following syntax, a Targa
  2204. image file is specified, the height field is smoothed, it is
  2205. given a simple white pigment, it is translated to center it
  2206. around the origin and it is scaled so that it resembles mountains
  2207. and fills the screen.
  2208.  
  2209.   height_field {
  2210.     tga "image.tga"
  2211.     smooth
  2212.     pigment { White }
  2213.     translate <-.5, -.5, -.5>
  2214.     scale <17, 1.75, 17>
  2215.   }
  2216. We save the file and render it at 320x240 -A. Later, when we are
  2217. satisfied that the height field is the way we want it, we render
  2218. it at a higher resolution with anti-aliasing.
  2219.  
  2220.                                 
  2221.          A height field created completely with POV-Ray.
  2222. Wow! The Himalayas have come to our computer screen!
  2223.  
  2224.  
  2225. 2.4.4     Lathe Object
  2226. In the real world, lathe refers to a process of making patterned
  2227. rounded shapes by spinning the source material in place and
  2228. carving pieces out as it turns. The results can be elaborate,
  2229. smoothly rounded, elegant looking artifacts such as table legs,
  2230. pottery, etc. In POV-Ray, a lathe object is used for creating
  2231. much the same kind of items, although we are referring to the
  2232. object itself rather than the means of production.
  2233.  
  2234. Here is some source for a really basic lathe (called
  2235. lathdem1.pov).
  2236.  
  2237.   #include "colors.inc"
  2238.   background{White}
  2239.   camera {
  2240.     angle 10
  2241.     location <1, 9, -50>
  2242.     look_at <0, 2, 0>
  2243.   }
  2244.   light_source {
  2245.     <20, 20, -20> color White
  2246.   }
  2247.   lathe {
  2248.     linear_spline
  2249.     6,
  2250.     <0,0>, <1,1>, <3,2>, <2,3>, <2,4>, <0,4>
  2251.     pigment { Blue }
  2252.     finish {
  2253.       ambient .3
  2254.       phong .75
  2255.     }
  2256.   }
  2257.                                 
  2258.                      A simple lathe object.
  2259. We render this, and what we see is a fairly simply type of lathe,
  2260. which looks like a child's top. Let's take a look at how this
  2261. code produced the effect.
  2262.  
  2263. First, a set of six points are declared which the raytracer
  2264. connects with lines. We note that there are only two components
  2265. in the vectors which describe these points. The lines that are
  2266. drawn are assumed to be in the x-y-plane, therefore it is as if
  2267. all the z-components were assumed to be zero. The use of a two-
  2268. dimensional vector is mandatory (Attempting to use a 3D vector
  2269. would trigger an error... with one exception, which we will
  2270. explore later in the discussion of splines).
  2271.  
  2272. Once the lines are determined, the ray-tracer rotates this line
  2273. around the y-axis, and we can imagine a trail being left through
  2274. space as it goes, with the surface of that trail being the
  2275. surface of our object.
  2276.  
  2277. The specified points are connected with straight lines because we
  2278. used the linear_spline keyword. There are other types of splines
  2279. available with the lathe, which will result in smooth curving
  2280. lines, and even rounded curving points of transition, but we will
  2281. get back to that in a moment.
  2282.  
  2283. First, we would like to digress a moment to talk about the
  2284. difference between a lathe and a surface of revolution object
  2285. (SOR). The SOR object, described in a separate tutorial, may seem
  2286. terribly similar to the lathe at first glance. It too declares a
  2287. series of points and connects them with curving lines and then
  2288. rotates them around the y-axis. The lathe has certain advantages,
  2289. such as different kinds of splines, linear, quadratic and cubic,
  2290. and one more thing:
  2291.  
  2292. The simpler mathematics used by a SOR doesn't allow the curve to
  2293. double back over the same y-coordinates, thus, if using a SOR,
  2294. any sudden twist which cuts back down over the same heights that
  2295. the curve previously covered will trigger an error. For example,
  2296. suppose we wanted a lathe to arc up from <0,0> to <2,2>, then to
  2297. dip back down to <4,0>. Rotated around the y-axis, this would
  2298. produce something like a gelatin mold - a rounded semi torus,
  2299. hollow in the middle. But with the SOR, as soon as the curve
  2300. doubled back on itself in the y-direction, it would become an
  2301. illegal declaration.
  2302.  
  2303. Still, the SOR has one powerful strong point: because it uses
  2304. simpler order mathematics, it generally tends to render faster
  2305. than an equivalent lathe. So in the end, its a matter of: we use
  2306. a SOR if its limitations will allow, but when we need a more
  2307. flexible shape, we go with the lathe instead.
  2308.  
  2309.  
  2310. 2.4.4.1   Understanding The Concept of Splines
  2311. It would be helpful, in order to understand splines, if we had a
  2312. sort of Spline Workshop where we could practice manipulating
  2313. types and points of splines and see what the effects were like.
  2314. So let's make one! Now that we know how to create a basic lathe,
  2315. it will be easy (see file lathdem2.pov):
  2316.  
  2317.   #include "colors.inc"
  2318.   camera {
  2319.     orthographic
  2320.     up <0, 5, 0>
  2321.     right <5, 0, 0>
  2322.     location <2.5, 2.5, -100>
  2323.     look_at <2.5, 2.5, 0>
  2324.   }
  2325.   /* set the control points to be used */
  2326.   #declare Red_Point    = <1.00, 0.00, 0>;
  2327.   #declare Orange_Point = <1.75, 1.00, 0>;
  2328.   #declare Yellow_Point = <2.50, 2.00, 0>;
  2329.   #declare Green_Point  = <2.00, 3.00, 0>;
  2330.   #declare Blue_Point   = <1.50, 4.00, 0>;
  2331.   /* make the control points visible */
  2332.   cylinder { Red_Point, Red_Point - 20*z, .1
  2333.     pigment { Red }
  2334.     finish { ambient 1 }
  2335.   }
  2336.   cylinder { Orange_Point, Orange_Point - 20*z, .1
  2337.     pigment { Orange }
  2338.     finish { ambient 1 }
  2339.   }
  2340.   cylinder { Yellow_Point, Yellow_Point - 20*z, .1
  2341.     pigment { Yellow }
  2342.     finish { ambient 1 }
  2343.   }
  2344.   cylinder { Green_Point, Green_Point - 20*z, .1
  2345.     pigment { Green }
  2346.     finish { ambient 1 }
  2347.   }
  2348.   cylinder { Blue_Point, Blue_Point- 20*z, .1
  2349.     pigment { Blue }
  2350.     finish { ambient 1 }
  2351.   }
  2352.   /* something to make the curve show up */
  2353.   lathe {
  2354.     linear_spline
  2355.     5,
  2356.     Red_Point,
  2357.     Orange_Point,
  2358.     Yellow_Point,
  2359.     Green_Point,
  2360.     Blue_Point
  2361.     pigment { White }
  2362.     finish { ambient 1 }
  2363.   }
  2364.                                 
  2365.                    A simple "Spline Workshop".
  2366. Now, we take a deep breath. We know that all looks a bit weird,
  2367. but with some simple explanations, we can easily see what all
  2368. this does.
  2369.  
  2370. First, we are using the orthographic camera. If we haven't read
  2371. up on that yet, a quick summary is: it renders the scene flat,
  2372. eliminating perspective distortion so that in a side view, the
  2373. objects look like they were drawn on a piece of graph paper (like
  2374. in the side view of a modeler or CAD package). There are several
  2375. uses for this practical new type of camera, but here it is
  2376. allowing us to see our lathe and cylinders edge on, so that what
  2377. we see is almost like a cross section of the curve which makes
  2378. the lathe, rather than the lathe itself. To further that effect,
  2379. we eliminated shadowing with the ambient 1 finish, which of
  2380. course also eliminates the need for lighting. We have also
  2381. positioned this particular side view so that <0,0> appears at the
  2382. lower left of our scene.
  2383.  
  2384. Next, we declared a set of points. We note that we used 3D
  2385. vectors for these points rather than the 2D vectors we expect in
  2386. a lathe. That's the exception we mentioned earlier. When we
  2387. declare a 3D point, then use it in a lathe, the lathe only uses
  2388. the first two components of the vector, and whatever is in the
  2389. third component is simply ignored. This is handy here, since it
  2390. makes this example possible.
  2391.  
  2392. Next we do two things with the declared points. First we use them
  2393. to place small diameter cylinders at the locations of the points
  2394. with the circular caps facing the camera. Then we re-use those
  2395. same vectors to determine the lathe. Since trying to declare a 2D
  2396. vector can have some odd results, and isn't really what our
  2397. cylinder declarations need anyway, we can take advantage of the
  2398. lathe's tendency to ignore the third component by just setting
  2399. the z-coordinate in these 3D vectors to zero.
  2400.  
  2401. The end result is: when we render this code, we see a white lathe
  2402. against a black background showing us how the curve we've
  2403. declared looks, and the circular ends of the cylinders show us
  2404. where along the x-y-plane our control points are. In this case,
  2405. it's very simple. The linear spline has been used so our curve is
  2406. just straight lines zig-zagging between the points. We change the
  2407. declarations of Red_Point and Blue_Point to read as follows (see
  2408. file lathdem3.pov).
  2409.  
  2410.   #declare Red_Point  = <2.00, 0.00, 0>;
  2411.   #declare Blue_Point = <0.00, 4.00, 0>;
  2412.                                 
  2413.                 Moving some points of the spline.
  2414. We re-render and, as we can see, all that happens is that the
  2415. straight line segments just move to accommodate the new position
  2416. of the red and blue points. Linear splines are so simple, we
  2417. could manipulate them in our sleep, no?
  2418.  
  2419. Let's try something different. First, we change the points to the
  2420. following (see file lathdem4.pov).
  2421.  
  2422.   #declare Red_Point    = <1.00, 0.00, 0>;
  2423.   #declare Orange_Point = <2.00, 1.00, 0>;
  2424.   #declare Yellow_Point = <3.50, 2.00, 0>;
  2425.   #declare Green_Point  = <2.00, 3.00, 0>;
  2426.   #declare Blue_Point   = <1.50, 4.00, 0>;
  2427.                                 
  2428.                     A quadratic spline lathe.
  2429. We then go down to the lathe declaration and change linear_spline
  2430. to quadratic_spline. We re-render and what do we have?  Well,
  2431. there's a couple of things worthy of note this time. First, we
  2432. will see that instead of straight lines we have smooth arcs
  2433. connecting the points. These arcs are made from quadratic curves,
  2434. so our lathe looks much more interesting this time. Also,
  2435. Red_Point is no longer connected to the curve. What happened?
  2436.  
  2437. Well, while any two points can determine a straight line, it
  2438. takes three to determine a quadratic curve. POV-Ray looks not
  2439. only to the two points to be connected, but to the point
  2440. immediately preceding them to determine the formula of the
  2441. quadratic curve that will be used to connect them. The problem
  2442. comes in at the beginning of the curve. Beyond the first point in
  2443. the curve there is no previous point. So we need to declare one.
  2444. Therefore, when using a quadratic spline, we must remember that
  2445. the first point we specify is only there so that POV-Ray can
  2446. determine what curve to connect the first two points with. It
  2447. will not show up as part of the actual curve.
  2448.  
  2449. There's just one more thing about this lathe example. Even though
  2450. our curve is now put together with smooth curving lines, the
  2451. transitions between those lines is... well, kind of choppy, no?
  2452. This curve looks like the lines between each individual point
  2453. have been terribly mismatched. Depending on what we are trying to
  2454. make, this could be acceptable, or, we might long for a more
  2455. smoothly curving shape. Fortunately, if the latter is true, we
  2456. have another option.
  2457.  
  2458. The quadratic spline takes longer to render than a linear spline.
  2459. The math is more complex. Still longer needs the cubic spline,
  2460. yet, for a really smoothed out shape, this is the only way to go.
  2461. We go back into our example, and simply replace quadratic_spline
  2462. with cubic_spline (see file lathdem5.pov). We render one more
  2463. time, and take a look at what we have.
  2464.  
  2465.                                 
  2466.                       A cubic spline lathe.
  2467. While a quadratic spline takes three points to determine the
  2468. curve, a cubic needs four. So, as we might expect, Blue_Point has
  2469. now dropped out of the curve, just as Red_Point did, as the first
  2470. and last points of our curve are now only control points for
  2471. shaping the curves between the remaining points. But look at the
  2472. transition from Orange_Point to Yellow_Point and then back to
  2473. Green_Point. Now, rather than looking mismatched, our curve
  2474. segments look like one smoothly joined curve.
  2475.  
  2476. The concept of splines is a handy and necessary one, which will
  2477. be seen again in the prism and polygon objects. But with a little
  2478. tinkering we can quickly get a feel for working with them.
  2479.  
  2480.  
  2481. 2.4.5     Mesh Object
  2482. Mesh objects are very useful because they allow us to create
  2483. objects containing hundreds or thousands of triangles. Compared
  2484. to a simple union of triangles the mesh object stores the
  2485. triangles more efficiently. Copies of mesh objects need only a
  2486. little additional memory because the triangles are stored only
  2487. once.
  2488.  
  2489. Almost every object can be approximated using triangles but we
  2490. may need a lot of triangles to create more complex shapes. Thus
  2491. we will only create a very simple mesh example. This example will
  2492. show a very useful feature of the triangles meshes though: a
  2493. different texture can be assigned to each triangle in the mesh.
  2494.  
  2495. Now let's begin. We will create a simple box with differently
  2496. colored sides. We create an empty file called meshdemo.pov and
  2497. add the following lines.
  2498.  
  2499.   camera {
  2500.     location <20, 20, -50>
  2501.     look_at <0, 5, 0>
  2502.   }
  2503.   light_source { <50, 50, -50> color rgb<1, 1, 1> }
  2504.   #declare Red = texture {
  2505.     pigment { color rgb<0.8, 0.2, 0.2> }
  2506.     finish { ambient 0.2 diffuse 0.5 }
  2507.   }
  2508.   #declare Green = texture {
  2509.     pigment { color rgb<0.2, 0.8, 0.2> }
  2510.     finish { ambient 0.2 diffuse 0.5 }
  2511.   }
  2512.   #declare Blue = texture {
  2513.     pigment { color rgb<0.2, 0.2, 0.8> }
  2514.     finish { ambient 0.2 diffuse 0.5 }
  2515.   }
  2516. We must declare all textures we want to use inside the mesh
  2517. before the mesh is created. Textures cannot be specified inside
  2518. the mesh due to the poor memory performance that would result.
  2519.  
  2520. Now we add the mesh object. Three sides of the box will use
  2521. individual textures while the other will use the global mesh
  2522. texture.
  2523.  
  2524.   mesh {
  2525.     /* top side */
  2526.     triangle { <-10, 10, -10>, <10, 10, -10>, <10, 10, 10>
  2527.       texture { Red }
  2528.     }
  2529.     triangle { <-10, 10, -10>, <-10, 10, 10>, <10, 10, 10>
  2530.       texture { Red }
  2531.     }
  2532.     /* bottom side */
  2533.     triangle { <-10, -10, -10>, <10, -10, -10>, <10, -10, 10> }
  2534.     triangle { <-10, -10, -10>, <-10, -10, 10>, <10, -10, 10> }
  2535.     /* left side */
  2536.     triangle { <-10, -10, -10>, <-10, -10, 10>, <-10, 10, 10> }
  2537.     triangle { <-10, -10, -10>, <-10, 10, -10>, <-10, 10, 10> }
  2538.     /* right side */
  2539.     triangle { <10, -10, -10>, <10, -10, 10>, <10, 10, 10>
  2540.       texture { Green }
  2541.     }
  2542.     triangle { <10, -10, -10>, <10, 10, -10>, <10, 10, 10>
  2543.       texture { Green }
  2544.     }
  2545.     /* front side */
  2546.     triangle { <-10, -10, -10>, <10, -10, -10>, <-10, 10, -10>
  2547.       texture { Blue }
  2548.     }
  2549.     triangle { <-10, 10, -10>, <10, 10, -10>, <10, -10, -10>
  2550.       texture { Blue }
  2551.     }
  2552.     /* back side */
  2553.     triangle { <-10, -10, 10>, <10, -10, 10>, <-10, 10, 10> }
  2554.     triangle { <-10, 10, 10>, <10, 10, 10>, <10, -10, 10> }
  2555.     texture {
  2556.       pigment { color rgb<0.9, 0.9, 0.9> }
  2557.       finish { ambient 0.2 diffuse 0.7 }
  2558.     }
  2559.   }
  2560. Tracing the scene at 320x240 we will see that the top, right and
  2561. front side of the box have different textures. Though this is not
  2562. a very impressive example it shows what we can do with mesh
  2563. objects. More complex examples, also using smooth triangles, can
  2564. be found under the scene directory as chesmsh.pov and
  2565. robotmsh.pov.
  2566.  
  2567.  
  2568. 2.4.6     Polygon Object
  2569. The polygon object can be used to create any planar, n-sided
  2570. shapes like squares, rectangles, pentagons, hexagons, octagons,
  2571. etc.
  2572.  
  2573. A polygon is defined by a number of points that describe its
  2574. shape. Since polygons have to be closed the first point has to be
  2575. repeated at the end of the point sequence.
  2576.  
  2577. In the following example we will create the word "POV" using just
  2578. one polygon statement.
  2579.  
  2580. We start with thinking about the points we need to describe the
  2581. desired shape. We want the letters to lie in the x-y-plane with
  2582. the letter O being at the center. The letters extend from y=0 to
  2583. y=1. Thus we get the following points for each letter (the z
  2584. coordinate is automatically set to zero).
  2585.  
  2586. Letter P (outer polygon):
  2587.     <-0.8, 0.0>, <-0.8, 1.0>,
  2588.     <-0.3, 1.0>, <-0.3, 0.5>,
  2589.     <-0.7, 0.5>, <-0.7, 0.0>
  2590. Letter P (inner polygon):
  2591.     <-0.7, 0.6>, <-0.7, 0.9>,
  2592.     <-0.4, 0.9>, <-0.4, 0.6>
  2593. Letter O (outer polygon):
  2594.     <-0.25, 0.0>, <-0.25, 1.0>,
  2595.     < 0.25, 1.0>, < 0.25, 0.0>
  2596. Letter O (inner polygon):
  2597.     <-0.15, 0.1>, <-0.15, 0.9>,
  2598.     < 0.15, 0.9>, < 0.15, 0.1>
  2599. Letter V:
  2600.     <0.45, 0.0>, <0.30, 1.0>,
  2601.     <0.40, 1.0>, <0.55, 0.1>,
  2602.     <0.70, 1.0>, <0.80, 1.0>,
  2603.     <0.65, 0.0>
  2604. Both letters P and O have a hole while the letter V consists of
  2605. only one polygon. We'll start with the letter V because it is
  2606. easier to define than the other two letters.
  2607.  
  2608. We create a new file called polygdem.pov and add the following
  2609. text.
  2610.  
  2611.   camera {
  2612.     orthographic
  2613.     location <0, 0, -10>
  2614.     right 1.3 * 4/3 * x
  2615.     up 1.3 * y
  2616.     look_at <0, 0.5, 0>
  2617.   }
  2618.   light_source { <25, 25, -100> color rgb 1 }
  2619.   polygon {
  2620.     8,
  2621.     <0.45, 0.0>, <0.30, 1.0>, // Letter "V"
  2622.     <0.40, 1.0>, <0.55, 0.1>,
  2623.     <0.70, 1.0>, <0.80, 1.0>,
  2624.     <0.65, 0.0>,
  2625.     <0.45, 0.0>
  2626.     pigment { color rgb <1, 0, 0> }
  2627.   }
  2628. As noted above the polygon has to be closed by appending the
  2629. first point to the point sequence. A closed polygon is always
  2630. defined by a sequence of points that ends when a point is the
  2631. same as the first point.
  2632.  
  2633. After we have created the letter V we'll continue with the letter
  2634. P. Since it has a hole we have to find a way of cutting this hole
  2635. into the basic shape. This is quite easy. We just define the
  2636. outer shape of the letter P, which is a closed polygon, and add
  2637. the sequence of points that describes the hole, which is also a
  2638. closed polygon. That's all we have to do. There'll be a hole
  2639. where both polygons overlap.
  2640.  
  2641. In general we will get holes whenever an even number of sub-
  2642. polygons inside a single polygon statement overlap. A sub-polygon
  2643. is defined by a closed sequence of points.
  2644.  
  2645. The letter P consists of two sub-polygons, one for the outer
  2646. shape and one for the hole. Since the hole polygon overlaps the
  2647. outer shape polygon we'll get a hole.
  2648.  
  2649. After we have understood how multiple sub-polygons in a single
  2650. polygon statement work, it is quite easy to add the missing O
  2651. letter.
  2652.  
  2653. Finally, we get the complete word POV.
  2654.  
  2655.   polygon {
  2656.     30,
  2657.     <-0.8, 0.0>, <-0.8, 1.0>,    // Letter "P"
  2658.     <-0.3, 1.0>, <-0.3, 0.5>,    // outer shape
  2659.     <-0.7, 0.5>, <-0.7, 0.0>,
  2660.     <-0.8, 0.0>,
  2661.     <-0.7, 0.6>, <-0.7, 0.9>,    // hole
  2662.     <-0.4, 0.9>, <-0.4, 0.6>,
  2663.     <-0.7, 0.6>
  2664.     <-0.25, 0.0>, <-0.25, 1.0>,  // Letter "O"
  2665.     < 0.25, 1.0>, < 0.25, 0.0>,  // outer shape
  2666.     <-0.25, 0.0>,
  2667.     <-0.15, 0.1>, <-0.15, 0.9>,  // hole
  2668.     < 0.15, 0.9>, < 0.15, 0.1>,
  2669.     <-0.15, 0.1>,
  2670.     <0.45, 0.0>, <0.30, 1.0>,    // Letter "V"
  2671.     <0.40, 1.0>, <0.55, 0.1>,
  2672.     <0.70, 1.0>, <0.80, 1.0>,
  2673.     <0.65, 0.0>,
  2674.     <0.45, 0.0>
  2675.     pigment { color rgb <1, 0, 0> }
  2676.   }
  2677.                                 
  2678.          The word "POV" made with one polygon statement.
  2679.  
  2680. 2.4.7     Prism Object
  2681. The prism is essentially a polygon or closed curve which is swept
  2682. along a linear path. We can imagine the shape so swept leaving a
  2683. trail in space, and the surface of that trail is the surface of
  2684. our prism. The curve or polygon making up a prism's face can be a
  2685. composite of any number of sub-shapes, can use any kind of three
  2686. different splines, and can either keep a constant width as it is
  2687. swept, or slowly tapering off to a fine point on one end. But
  2688. before this gets too confusing, let's start one step at a time
  2689. with the simplest form of prism. We enter and render the
  2690. following POV code (see file prismdm1.pov).
  2691.  
  2692.   #include "colors.inc"
  2693.   background{White}
  2694.   camera {
  2695.     angle 20
  2696.     location <2, 10, -30>
  2697.     look_at <0, 1, 0>
  2698.   }
  2699.   light_source { <20, 20, -20> color White }
  2700.   prism {
  2701.     linear_sweep
  2702.     linear_spline
  2703.     0, // sweep the following shape from here ...
  2704.     1, // ... up through here
  2705.     7, // the number of points making up the shape ...
  2706.     <3,5>, <-3,5>, <-5,0>, <-3,-5>, <3, -5>, <5,0>, <3,5>
  2707.     pigment { Green }
  2708.   }
  2709.                                 
  2710.                     A hexagonal prism shape.
  2711. This produces a hexagonal polygon, which is then swept from y=0
  2712. through y=1. In other words, we now have an extruded hexagon. One
  2713. point to note is that although this is a six sided figure, we
  2714. have used a total of seven points. That is because the polygon is
  2715. supposed to be a closed shape, which we do here by making the
  2716. final point the same as the first. Technically, with linear
  2717. polygons, if we didn't do this, POV-Ray would automatically join
  2718. the two ends with a line to force it to close, although a warning
  2719. would be issued. However, this only works with linear splines, so
  2720. we mustn't get too casual about those warning messages!
  2721.  
  2722.  
  2723. 2.4.7.1   Teaching An Old Spline New Tricks
  2724. If we followed the section on splines covered under the lathe
  2725. tutorial (see section "Understanding The Concept of Splines"), we
  2726. know that there are two additional kinds of splines besides
  2727. linear: the quadratic and the cubic spline. Sure enough, we can
  2728. use these with prisms to make a more free form, smoothly curving
  2729. type of prism.
  2730.  
  2731. There is just one catch, and we should read this section
  2732. carefully to keep from tearing our hair out over mysterious "too
  2733. few points in prism" messages which keep our prism from
  2734. rendering. We can probably guess where this is heading: how to
  2735. close a non-linear spline. Unlike the linear spline, which simply
  2736. draws a line between the last and first points if we forget to
  2737. make the last point equal to the first, quadratic and cubic
  2738. splines are a little more fussy.
  2739.  
  2740. First of all, we remember that quadratic splines determine the
  2741. equation of the curve which connects any two points based on
  2742. those two points and the previous point, so the first point in
  2743. any quadratic spline is just control point and won't actually be
  2744. part of the curve.  What this means is: when we make our shape
  2745. out of a quadratic spline, we must match the second point to the
  2746. last, since the first point is not on the curve - it's just a
  2747. control point needed for computational purposes.
  2748.  
  2749. Likewise, cubic splines need both the first and last points to be
  2750. control points, therefore, to close a shape made with a cubic
  2751. spline, we must match the second point to the second from last
  2752. point. If we don't match the correct points on a quadratic or
  2753. cubic shape, that's when we will get the "too few points in
  2754. prism" error. POV-Ray is still waiting for us to close the shape,
  2755. and when it runs out of points without seeing the closure, an
  2756. error is issued.
  2757.  
  2758. Confused? Okay, how about an example? We replace the prism in our
  2759. last bit of code with this one (see file prismdm2.pov).
  2760.  
  2761.   prism {
  2762.     cubic_spline
  2763.     0, // sweep the following shape from here ...
  2764.     1, // ... up through here
  2765.     6, // the number of points making up the shape ...
  2766.     < 3, -5>, // point#1 (control point... not on curve)
  2767.     < 3,  5>, // point#2  ... THIS POINT ...
  2768.     <-5,  0>, // point#3
  2769.     < 3, -5>, // point#4
  2770.     < 3,  5>, // point#5 ... MUST MATCH THIS POINT
  2771.     <-5,  0>  // point#6 (control point... not on curve)
  2772.     pigment { Green }
  2773.   }
  2774.                                 
  2775.                 A cubic, triangular prism shape.
  2776. This simple prism produces what looks like an extruded triangle
  2777. with its corners sanded smoothly off. Points two, three and four
  2778. are the corners of the triangle and point five closes the shape
  2779. by returning to the location of point two. As for points one and
  2780. six, they are our control points, and aren't part of the shape -
  2781. they're just there to help compute what curves to use between the
  2782. other points.
  2783.  
  2784.  
  2785. 2.4.7.2   Smooth Transitions
  2786. Now a handy thing to note is that we have made point one equal
  2787. point four, and also point six equals point three. Yes, this is
  2788. important. Although this prism would still be legally closed if
  2789. the control points were not what we've made them, the curve
  2790. transitions between points would not be as smooth. We change
  2791. points one and six to <4,6> and <0,7> respectively and re-render
  2792. to see how the back edge of the shape is altered (see file
  2793. prismdm3.pov).
  2794.  
  2795. To put this more generally, if we want a smooth closure on a
  2796. cubic spline, we make the first control point equal to the third
  2797. from last point, and the last control point equal to the third
  2798. point. On a quadratic spline, the trick is similar, but since
  2799. only the first point is a control point, make that equal to the
  2800. second from last point.
  2801.  
  2802.  
  2803. 2.4.7.3   Multiple Sub-Shapes
  2804. Just as with the polygon object (see section "Polygon Object")
  2805. the prism is very flexible, and allows us to make one prism out
  2806. of several sub-prisms. To do this, all we need to do is keep
  2807. listing points after we have already closed the first shape. The
  2808. second shape can be simply an add on going off in another
  2809. direction from the first, but one of the more interesting
  2810. features is that if any even number of sub-shapes overlap, that
  2811. region where they overlap behaves as though it has been cut away
  2812. from both sub-shapes. Let's look at another example. Once again,
  2813. same basic code as before for camera, light and so forth, but we
  2814. substitute this complex prism (see file prismdm4.pov).
  2815.  
  2816.   prism {
  2817.     linear_sweep
  2818.     cubic_spline
  2819.     0,  // sweep the following shape from here ...
  2820.     1,  // ... up through here
  2821.     18, // the number of points making up the shape ...
  2822.     <3,-5>, <3,5>, <-5,0>, <3, -5>, <3,5>, <-5,0>, // sub-shape
  2823. #1
  2824.     <2,-4>, <2,4>, <-4,0>, <2,-4>, <2,4>, <-4,0>,  // sub-shape
  2825. #2
  2826.     <1,-3>, <1,3>, <-3,0>, <1, -3>, <1,3>, <-3,0>  // sub-shape
  2827. #3
  2828.     pigment { Green }
  2829.   }
  2830.                                 
  2831.         Using sub-shapes to create a more complex shape.
  2832. For readability purposes, we have started a new line every time
  2833. we moved on to a new sub-shape, but the ray-tracer of course
  2834. tells where each shape ends based on whether the shape has been
  2835. closed (as described earlier). We render this new prism, and look
  2836. what we've got. It's the same familiar shape, but it now looks
  2837. like a smaller version of the shape has been carved out of the
  2838. center, then the carved piece was sanded down even smaller and
  2839. set back in the hole.
  2840.  
  2841. Simply, the outer rim is where only sub-shape one exists, then
  2842. the carved out part is where sub-shapes one and two overlap. In
  2843. the extreme center, the object reappears because sub-shapes one,
  2844. two, and three overlap, returning us to an odd number of
  2845. overlapping pieces. Using this technique we could make any number
  2846. of extremely complex prism shapes!
  2847.  
  2848.  
  2849. 2.4.7.4   Conic Sweeps And The Tapering Effect
  2850. In our original prism, the keyword linear_sweep is actually
  2851. optional. This is the default sweep assumed for a prism if no
  2852. type of sweep is specified. But there is another, extremely
  2853. useful kind of sweep: the conic sweep. The basic idea is like the
  2854. original prism, except that while we are sweeping the shape from
  2855. the first height through the second height, we are constantly
  2856. expanding it from a single point until, at the second height, the
  2857. shape has expanded to the original points we made it from. To
  2858. give a small idea of what such effects are good for, we replace
  2859. our existing prism with this (see file prismdm4.pov):
  2860.  
  2861.   prism {
  2862.     conic_sweep
  2863.     linear_spline
  2864.     0, // height 1
  2865.     1, // height 2
  2866.     5, // the number of points making up the shape...
  2867.     <4,4>,<-4,4>,<-4,-4>,<4,-4>,<4,4>
  2868.     rotate <180, 0, 0>
  2869.     translate <0, 1, 0>
  2870.     scale <1, 4, 1>
  2871.     pigment { gradient y scale .2 }
  2872.   }
  2873.                                 
  2874.             Creating a pyramid using conic sweeping.
  2875. The gradient pigment was selected to give some definition to our
  2876. object without having to fix the lights and the camera angle
  2877. right at this moment, but when we render it, we what we've
  2878. created? A horizontally striped pyramid! By now we can recognize
  2879. the linear spline connecting the four points of a square, and the
  2880. familiar final point which is there to close the spline.
  2881.  
  2882. Notice all the transformations in the object declaration. That's
  2883. going to take a little explanation. The rotate and translate are
  2884. easy. Normally, a conic sweep starts full sized at the top, and
  2885. tapers to a point at y=0, but of course that would be upside down
  2886. if we're making a pyramid. So we flip the shape around the x-axis
  2887. to put it right side up, then since we actually orbited around
  2888. the point, we translate back up to put it in the same position it
  2889. was in when we started.
  2890.  
  2891. The scale is to put the proportions right for this example. The
  2892. base is eight units by eight units, but the height (from y=1 to
  2893. y=0) is only one unit, so we've stretched it out a little. At
  2894. this point, we're probably thinking, "why not just sweep up from
  2895. y=0 to y=4 and avoid this whole scaling thing?"
  2896.  
  2897. That is a very important gotcha! with conic sweeps. To see what's
  2898. wrong with that, let's try and put it into practice (see file
  2899. prismdm5.pov). We must make sure to remove the scale statement,
  2900. and then replace the line which reads
  2901.  
  2902.   1, // height 2
  2903. with
  2904.  
  2905.   4, // height 2
  2906. This sets the second height at y=4, so let's re-render and see if
  2907. the effect is the same.
  2908.  
  2909.                                 
  2910.   Choosing a second height larger than one for the conic sweep.
  2911. Whoa! Our height is correct, but our pyramid's base is now huge!
  2912. What went wrong here? Simple. The base, as we described it with
  2913. the points we used actually occurs at y=1 no matter what we set
  2914. the second height for. But if we do set the second height higher
  2915. than one, once the sweep passes y=1, it keeps expanding outward
  2916. along the same lines as it followed to our original base, making
  2917. the actual base bigger and bigger as it goes.
  2918.  
  2919. To avoid losing control of a conic sweep prism, it is usually
  2920. best to let the second height stay at y=1, and use a scale
  2921. statement to adjust the height from its unit size. This way we
  2922. can always be sure the base's corners remain where we think they
  2923. are.
  2924.  
  2925. That leads to one more interesting thing about conic sweeps. What
  2926. if we for some reason don't want them to taper all the way to a
  2927. point? What if instead of a complete pyramid, we want more of a
  2928. ziggurat step? Easily done. After putting the second height back
  2929. to one, and replacing our scale statement, we change the line
  2930. which reads
  2931.  
  2932.   0, // height 1
  2933. to
  2934.  
  2935.   0.251, // height 1
  2936.                                 
  2937.         Increasing the first height for the conic sweep.
  2938. When we re-render, we see that the sweep stops short of going all
  2939. the way to its point, giving us a pyramid without a cap. Exactly
  2940. how much of the cap is cut off depends on how close the first
  2941. height is to the second height.
  2942.  
  2943.  
  2944. 2.4.8     Superquadric Ellipsoid Object
  2945. Sometimes we want to make an object that does not have perfectly
  2946. sharp edges like a box does. Then, the superquadric ellipsoid
  2947. shape made by the superellipsoid is a useful object. It is
  2948. described by the simple syntax:
  2949.  
  2950.     superellipsoid { <Value_E, Value_N >}
  2951. Where Value_E and Value_N are float values greater than zero and
  2952. less than or equal to one. Let's make a superellipsoid and
  2953. experiment with the values of Value_E and Value_N to see what
  2954. kind of shapes we can make.
  2955.  
  2956. We create a file called supellps.pov and edit it as follows:
  2957.  
  2958.   #include "colors.inc"
  2959.   camera {
  2960.     location <10, 5, -20>
  2961.     look_at 0
  2962.     angle 15
  2963.   }
  2964.   background { color rgb <.5, .5, .5> }
  2965.   light_source { <10, 50, -100> White }
  2966. The addition of a gray background makes it a little easier to see
  2967. our object. We now type:
  2968.  
  2969.   superellipsoid { <.25, .25>
  2970.     pigment { Red }
  2971.   }
  2972. We save the file and trace it at 200x150 -A to see the shape. It
  2973. will look like a box, but the edges will be rounded off. Now
  2974. let's experiment with different values of Value_E and Value_N.
  2975. For the next trace, try <1, 0.2>. The shape now looks like a
  2976. cylinder, but the top edges are rounded. Now try <0.1, 1>. This
  2977. shape is an odd one! We don't know exactly what to call it, but
  2978. it is interesting. Finally, lets try <1, 1>. Well, this is more
  2979. familiar... a sphere!
  2980.  
  2981. There are a couple of facts about superellipsoids we should know.
  2982. First, we should not use a value of 0 for either Value_E nor
  2983. Value_N. This will cause POV-Ray to incorrectly make a black box
  2984. instead of our desired shape. Second, very small values of
  2985. Value_E and Value_N may yield strange results so they should be
  2986. avoided. Finally, the Sturmian root solver will not work with
  2987. superellipsoids.
  2988.  
  2989. Superellipsoids are finite objects so they respond to auto-
  2990. bounding and can be used in CSG.
  2991.  
  2992. Now let's use the superellipsoid to make something that would be
  2993. useful in a scene. We will make a tiled floor and place a couple
  2994. of superellipsoid objects hovering over it. We can start with the
  2995. file we have already made.
  2996.  
  2997. We rename it to tiles.pov and edit it so that it reads as
  2998. follows:
  2999.  
  3000.   #include "colors.inc"
  3001.   #include "textures.inc"
  3002.   camera {
  3003.     location <10, 5, -20>
  3004.     look_at 0
  3005.     angle 15
  3006.   }
  3007.   background { color rgb <.5, .5, .5> }
  3008.   light_source{ <10, 50, -100> White }
  3009. Note that we have added #include "textures.inc" so we can use pre-
  3010. defined textures. Now we want to define the superellipsoid which
  3011. will be our tile.
  3012.  
  3013.   #declare Tile = superellipsoid { <0.5, 0.1>
  3014.     scale <1, .05, 1>
  3015.   }
  3016. Superellipsoids are roughly 2*2*2 units unless we scale them
  3017. otherwise. If we wish to lay a bunch of our tiles side by side,
  3018. they will have to be offset from each other so they don't
  3019. overlap. We should select an offset value that is slightly more
  3020. than 2 so that we have some space between the tiles to fill with
  3021. grout. So we now add this:
  3022.  
  3023.   #declare Offset = 2.1;
  3024. We now want to lay down a row of tiles. Each tile will be offset
  3025. from the original by an ever-increasing amount in both the +z and
  3026. -z directions. We refer to our offset and multiply by the tile's
  3027. rank to determine the position of each tile in the row. We also
  3028. union these tiles into a single object called Row like this:
  3029.  
  3030.   #declare Row = union {
  3031.     object { Tile }
  3032.     object { Tile translate z*Offset }
  3033.     object { Tile translate z*Offset*2 }
  3034.     object { Tile translate z*Offset*3 }
  3035.     object { Tile translate z*Offset*4 }
  3036.     object { Tile translate z*Offset*5 }
  3037.     object { Tile translate z*Offset*6 }
  3038.     object { Tile translate z*Offset*7 }
  3039.     object { Tile translate z*Offset*8 }
  3040.     object { Tile translate z*Offset*9 }
  3041.     object { Tile translate z*Offset*10 }
  3042.     object { Tile translate -z*Offset }
  3043.     object { Tile translate -z*Offset*2 }
  3044.     object { Tile translate -z*Offset*3 }
  3045.     object { Tile translate -z*Offset*4 }
  3046.     object { Tile translate -z*Offset*5 }
  3047.     object { Tile translate -z*Offset*6 }
  3048.   }
  3049. This gives us a single row of 17 tiles, more than enough to fill
  3050. the screen. Now we must make copies of the Row and translate
  3051. them, again by the offset value, in both the +x and -x directions
  3052. in ever increasing amounts in the same manner.
  3053.  
  3054.   object { Row }
  3055.   object { Row translate x*Offset }
  3056.   object { Row translate x*Offset*2 }
  3057.   object { Row translate x*Offset*3 }
  3058.   object { Row translate x*Offset*4 }
  3059.   object { Row translate x*Offset*5 }
  3060.   object { Row translate x*Offset*6 }
  3061.   object { Row translate x*Offset*7 }
  3062.   object { Row translate -x*Offset }
  3063.   object { Row translate -x*Offset*2 }
  3064.   object { Row translate -x*Offset*3 }
  3065.   object { Row translate -x*Offset*4 }
  3066.   object { Row translate -x*Offset*5 }
  3067.   object { Row translate -x*Offset*6 }
  3068.   object { Row translate -x*Offset*7 }
  3069. Finally, our tiles are complete. But we need a texture for them.
  3070. To do this we union all of the Rows together and apply a White
  3071. Marble pigment and a somewhat shiny reflective surface to it:
  3072.  
  3073.   union{
  3074.     object { Row }
  3075.     object { Row translate x*Offset }
  3076.     object { Row translate x*Offset*2 }
  3077.     object { Row translate x*Offset*3 }
  3078.     object { Row translate x*Offset*4 }
  3079.     object { Row translate x*Offset*5 }
  3080.     object { Row translate x*Offset*6 }
  3081.     object { Row translate x*Offset*7 }
  3082.     object { Row translate -x*Offset }
  3083.     object { Row translate -x*Offset*2 }
  3084.     object { Row translate -x*Offset*3 }
  3085.     object { Row translate -x*Offset*4 }
  3086.     object { Row translate -x*Offset*5 }
  3087.     object { Row translate -x*Offset*6 }
  3088.     object { Row translate -x*Offset*7 }
  3089.     pigment { White_Marble }
  3090.     finish { phong 1 phong_size 50 reflection .35 }
  3091.   }
  3092. We now need to add the grout. This can simply be a white plane.
  3093. We have stepped up the ambient here a little so it looks whiter.
  3094.  
  3095.   plane { y, 0  //this is the grout
  3096.     pigment { color White }
  3097.     finish { ambient .4 diffuse .7 }
  3098.   }
  3099. To complete our scene, let's add five different superellipsoids,
  3100. each a different color, so that they hover over our tiles and are
  3101. reflected in them.
  3102.  
  3103.   superellipsoid {
  3104.     <0.1, 1>
  3105.     pigment { Red }
  3106.     translate <5, 3, 0>
  3107.     scale .45
  3108.   }
  3109.   superellipsoid {
  3110.     <1, 0.25>
  3111.     pigment { Blue }
  3112.     translate <-5, 3, 0>
  3113.     scale .45
  3114.   }
  3115.   superellipsoid {
  3116.     <0.2, 0.6>
  3117.     pigment { Green }
  3118.     translate <0, 3, 5>
  3119.     scale .45
  3120.   }
  3121.   superellipsoid {
  3122.     <0.25, 0.25>
  3123.     pigment { Yellow }
  3124.     translate <0, 3, -5>
  3125.     scale .45
  3126.   }
  3127.   superellipsoid {
  3128.     <1, 1>
  3129.     pigment { Pink }
  3130.     translate y*3
  3131.     scale .45
  3132.   }
  3133.                                 
  3134.        Some superellipsoids hovering above a tiled floor.
  3135. We trace the scene at 320x200 -A to see the result. If we are
  3136. happy with that, we do a final trace at 640x480 +A0.2.
  3137.  
  3138.  
  3139. 2.4.9     Surface of Revolution Object
  3140. Bottles, vases and glasses make nice objects in ray-traced
  3141. scenes. We want to create a golden cup using the surface of
  3142. revolution object (SOR object).
  3143.  
  3144. We first start by thinking about the shape of the final object.
  3145. It is quite difficult to come up with a set of points that
  3146. describe a given curve without the help of a modeling program
  3147. supporting POV-Ray's surface of revolution object. If such a
  3148. program is available we should take advantage of it.
  3149.  
  3150.                                 
  3151.            The point configuration of our cup object.
  3152. We will use the point configuration shown in the figure above.
  3153. There are eight points describing the curve that will be rotated
  3154. about the y-axis to get our cup. The curve was calculated using
  3155. the method described in the reference section (see "Surface of
  3156. Revolution").
  3157.  
  3158. Now it is time to come up with a scene that uses the above SOR
  3159. object. We edit a file called sordemo.pov and enter the following
  3160. text.
  3161.  
  3162.   #include "colors.inc"
  3163.   #include "golds.inc"
  3164.   global_settings { assumed_gamma 2.2 }
  3165.   camera {
  3166.     location <10, 15, -20>
  3167.     look_at <0, 5, 0>
  3168.     angle 45
  3169.   }
  3170.   background { color rgb<0.2, 0.4, 0.8>  }
  3171.   light_source { <100, 100, -100> color rgb 1 }
  3172.   plane { y, 0
  3173.     pigment { checker color Red, color Green scale 10 }
  3174.   }
  3175.   sor {
  3176.     8,
  3177.     <0.0,  -0.5>,
  3178.     <3.0,   0.0>,
  3179.     <1.0,   0.2>,
  3180.     <0.5,   0.4>,
  3181.     <0.5,   4.0>,
  3182.     <1.0,   5.0>,
  3183.     <3.0,  10.0>,
  3184.     <4.0,  11.0>
  3185.     texture { T_Gold_1B }
  3186.   }
  3187. The scene contains our cup object resting on a checkered plane.
  3188. Tracing this scene results in the image below.
  3189.  
  3190.                                 
  3191.                  A surface of revolution object.
  3192. The surface of revolution is described by starting with the
  3193. number of points followed by the points with ascending heights.
  3194. Each point determines the radius of the curve for a given height.
  3195. E. g. the first point tells POV-Ray that at height -0.5 the
  3196. radius is 0. We should take care that each point has a larger
  3197. height than its predecessor. If this is not the case the program
  3198. will abort with an error message.
  3199.  
  3200.  
  3201. 2.4.10    Text Object
  3202. Creating text objects using POV-Ray always used to mean that the
  3203. letters had to be built either from CSG, a painstaking process or
  3204. by using a black and white image of the letters as a height
  3205. field, a method that was only somewhat satisfactory. Now, for POV-
  3206. Ray 3.0, a new primitive has been introduced that can use any
  3207. TrueType font to create text objects. These objects can be used
  3208. in CSG, transformed and textured just like any other POV
  3209. primitive.
  3210.  
  3211. For this tutorial, we will make two uses of the text object.
  3212. First, let's just make some block letters sitting on a checkered
  3213. plane. Any TTF font should do, but for this tutorial, we will use
  3214. the timrom.ttf or cyrvetic.ttf which come bundled with POV-Ray.
  3215. We create a file called textdemo.pov and edit it as follows:
  3216.  
  3217.   #include "colors.inc"
  3218.   camera {
  3219.     location <0, 1, -10>
  3220.     look_at 0
  3221.     angle 35
  3222.   }
  3223.   light_source { <500,500,-1000> White }
  3224.   plane { y,0
  3225.     pigment { checker Green White }
  3226.   }
  3227. Now let's add the text object. We will use the font timrom.ttf
  3228. and we will create the string "POV-RAY 3.0". For now, we will
  3229. just make the letters red. The syntax is very simple. The first
  3230. string in quotes is the font name, the second one is the string
  3231. to be rendered. The two floats are the thickness and offset
  3232. values. The thickness float determines how thick the block
  3233. letters will be. Values of .5 to 2 are usually best for this. The
  3234. offset value will add to the kerning distance of the letters. We
  3235. will leave this a 0 for now.
  3236.  
  3237.   text { ttf "timrom.ttf" "POV-RAY 3.0" 1, 0
  3238.     pigment { Red }
  3239.   }
  3240. Rendering this at 200x150 -A, we notice that the letters are off
  3241. to the right of the screen. This is because they are placed so
  3242. that the lower left front corner of the first letter is at the
  3243. origin. To center the string we need to translate it -x some
  3244. distance. But how far? In the docs we see that the letters are
  3245. all 0.5 to 0.75 units high. If we assume that each one takes
  3246. about 0.5 units of space on the x-axis, this means that the
  3247. string is about 6 units long (12 characters and spaces). Let's
  3248. translate the string 3 units along the negative x-axis.
  3249.  
  3250.   text { ttf "timrom.ttf" "POV-RAY 3.0" 1, 0
  3251.     pigment { Red }
  3252.     translate -3*x
  3253.   }
  3254. That's better. Now let's play around with some of the parameters
  3255. of the text object. First, let's raise the thickness float to
  3256. something outlandish... say 25!
  3257.  
  3258.   text { ttf "timrom.ttf" "POV-RAY 3.0" 25, 0
  3259.     pigment { Red }
  3260.     translate -2.25*x
  3261.   }
  3262. Actually, that's kind of cool. Now let's return the thickness
  3263. value to 1 and try a different offset value. Change the offset
  3264. float from 0 to 0.1 and render it again.
  3265.  
  3266. Wait a minute?! The letters go wandering off up at an angle! That
  3267. is not what the docs describe! It almost looks as if the offset
  3268. value applies in both the x- and y-axis instead of just the x
  3269. axis like we intended. Could it be that a vector is called for
  3270. here instead of a float? Let's try it. We replace 0.1 with 0.1*x
  3271. and render it again.
  3272.  
  3273. That works! The letters are still in a straight line along the x-
  3274. axis, just a little further apart. Let's verify this and try to
  3275. offset just in the y-axis. We replace 0.1*x with 0.1*y. Again,
  3276. this works as expected with the letters going up to the right at
  3277. an angle with no additional distance added along the x-axis. Now
  3278. let's try the z-axis. We replace 0.1*y with 0.1*z. Rendering this
  3279. yields a disappointment. No offset occurs! The offset value can
  3280. only be applied in the x- and y-directions.
  3281.  
  3282. Let's finish our scene by giving a fancier texture to the block
  3283. letters, using that cool large thickness value, and adding a
  3284. slight y-offset. For fun, we will throw in a sky sphere, dandy up
  3285. our plane a bit, and use a little more interesting camera
  3286. viewpoint (we render the following scene at 640x480 +A0.2):
  3287.  
  3288.   #include "colors.inc"
  3289.   camera {
  3290.     location <-5,.15,-2>
  3291.     look_at <.3,.2,1>
  3292.     angle 35
  3293.   }
  3294.   light_source { <500,500,-1000> White }
  3295.   plane { y,0
  3296.     texture {
  3297.       pigment { SeaGreen }
  3298.       finish { reflection .35 specular 1 }
  3299.       normal { ripples .35 turbulence .5 scale .25 }
  3300.     }
  3301.   }
  3302.   text { ttf "timrom.ttf" "POV-RAY 3.0" 25, 0.1*y
  3303.     pigment { BrightGold }
  3304.     finish { reflection .25 specular 1 }
  3305.     translate -3*x
  3306.   }
  3307.   #include "skies.inc"
  3308.   sky_sphere { S_Cloud5 }
  3309. Let's try using text in a CSG object. We will attempt to create
  3310. an inlay in a stone block using a text object. We create a new
  3311. file called textcsg.pov and edit it as follows:
  3312.  
  3313.   #include "colors.inc"
  3314.   #include "stones.inc"
  3315.   background { color rgb 1 }
  3316.   camera {
  3317.     location <-3, 5, -15>
  3318.     look_at 0
  3319.     angle 25
  3320.   }
  3321.   light_source { <500,500,-1000> White }
  3322. Now let's create the block. We want it to be about eight units
  3323. across because our text string "POV-RAY 3.0" is about six units
  3324. long. We also want it about four units high and about one unit
  3325. deep. But we need to avoid a potential coincident surface with
  3326. the text object so we will make the first z-coordinate 0.1
  3327. instead of 0. Finally, we will give this block a nice stone
  3328. texture.
  3329.  
  3330.   box { <-3.5, -1, 0.1>, <3.5, 1, 1>
  3331.     texture { T_Stone10 }
  3332.   }
  3333. Next, we want to make the text object. We can use the same object
  3334. we used in the first tutorial except we will use slightly
  3335. different thickness and offset values.
  3336.  
  3337.   text { ttf "timrom.ttf" "POV-RAY 3.0" 0.15, 0
  3338.     pigment { BrightGold }
  3339.     finish { reflection .25 specular 1 }
  3340.     translate -3*x
  3341.   }
  3342. We remember that the text object is placed by default so that its
  3343. front surface lies directly on the x-y-plane. If the front of the
  3344. box begins at z=0.1 and thickness is set at 0.15, the depth of
  3345. the inlay will be 0.05 units. We place a difference block around
  3346. the two objects.
  3347.  
  3348.   difference {
  3349.     box { <-3.5, -1, 0.1>, <3.5, 1, 1>
  3350.       texture { T_Stone10 }
  3351.     }
  3352.     text { ttf "timrom.ttf" "POV-RAY 3.0" 0.15, 0
  3353.       pigment { BrightGold }
  3354.       finish { reflection .25 specular 1 }
  3355.       translate -3*x
  3356.     }
  3357.   }
  3358.                                 
  3359.                      Text carved from stone.
  3360. We render this at 200x150 -A. We can see the inlay clearly and
  3361. that it is indeed a bright gold color. We re-render at 640x480
  3362. +A0.2 to see the results more clearly, but be forewarned... this
  3363. trace will take a little time.
  3364.  
  3365.  
  3366. 2.4.11    Torus Object
  3367. A torus can be thought of as a donut or an inner-tube. It is a
  3368. shape that is vastly useful in many kinds of CSG so POV-Ray has
  3369. adopted this 4th order quartic polynomial as a primitive shape.
  3370. The syntax for a torus is so simple that it makes it a very easy
  3371. shape to work with once we learn what the two float values mean.
  3372. Instead of a lecture on the subject, let's create one and do some
  3373. experiments with it.
  3374.  
  3375. We create a file called tordemo.pov and edit it as follows:
  3376.  
  3377.   #include "colors.inc"
  3378.   camera {
  3379.     location <0, .1, -25>
  3380.     look_at 0
  3381.     angle 30
  3382.   }
  3383.   background { color Gray50 } // to make the torus easy to see
  3384.   light_source{ <300, 300, -1000> White }
  3385.   torus { 4, 1        // major and minor radius
  3386.     rotate -90*x      // so we can see it from the top
  3387.     pigment { Green }
  3388.   }
  3389. We trace the scene. Well, it's a donut alright. Let's try
  3390. changing the major and minor radius values and see what happens.
  3391. We change them as follows:
  3392.  
  3393.   torus { 5, .25      // major and minor radius
  3394. That looks more like a hula-hoop! Let's try this:
  3395.  
  3396.   torus { 3.5, 2.5    // major and minor radius
  3397. Whoa! A donut with a serious weight problem!
  3398.  
  3399. With such a simple syntax, there isn't much else we can do to a
  3400. torus besides change its texture... or is there? Let's see...
  3401.  
  3402. Torii are very useful objects in CSG. Let's try a little
  3403. experiment. We make a difference of a torus and a box:
  3404.  
  3405.   difference {
  3406.     torus { 4, 1
  3407.       rotate x*-90  // so we can see it from the top
  3408.     }
  3409.     box { <-5, -5, -1>, <5, 0, 1> }
  3410.     pigment { Green }
  3411.   }
  3412. Interesting... a half-torus. Now we add another one flipped the
  3413. other way. Only, let's declare the original half-torus and the
  3414. necessary transformations so we can use them again:
  3415.  
  3416.   #declare Half_Torus = difference {
  3417.     torus { 4, 1
  3418.       rotate -90*x  // so we can see it from the top
  3419.     }
  3420.     box { <-5, -5, -1>, <5, 0, 1> }
  3421.     pigment { Green }
  3422.   }
  3423.   #declare Flip_It_Over = 180*x;
  3424.   #declare Torus_Translate = 8;  // twice the major radius
  3425. Now we create a union of two Half_Torus objects:
  3426.  
  3427.   union {
  3428.     object { Half_Torus }
  3429.     object { Half_Torus
  3430.       rotate Flip_It_Over
  3431.       translate Torus_Translate*x
  3432.     }
  3433.   }
  3434. This makes an S-shaped object, but we can't see the whole thing
  3435. from our present camera. Let's add a few more links, three in
  3436. each direction, move the object along the +z-direction and rotate
  3437. it about the +y-axis so we can see more of it. We also notice
  3438. that there appears to be a small gap where the half Torii meet.
  3439. This is due to the fact that we are viewing this scene from
  3440. directly on the x-z-plane. We will change the camera's y-
  3441. coordinate from 0 to 0.1 to eliminate this.
  3442.  
  3443.   union {
  3444.     object { Half_Torus }
  3445.     object { Half_Torus
  3446.       rotate Flip_It_Over
  3447.       translate x*Torus_Translate
  3448.     }
  3449.     object { Half_Torus
  3450.       translate x*Torus_Translate*2
  3451.     }
  3452.     object { Half_Torus
  3453.       rotate Flip_It_Over
  3454.       translate x*Torus_Translate*3
  3455.     }
  3456.     object { Half_Torus
  3457.       rotate Flip_It_Over
  3458.       translate -x*Torus_Translate
  3459.     }
  3460.     object { Half_Torus
  3461.       translate -x*Torus_Translate*2
  3462.     }
  3463.     object { Half_Torus
  3464.       rotate Flip_It_Over
  3465.       translate -x*Torus_Translate*3
  3466.     }
  3467.     object { Half_Torus
  3468.       translate -x*Torus_Translate*4
  3469.     }
  3470.     rotate y*45
  3471.     translate z*20
  3472.   }
  3473. Rendering this we see a cool, undulating, snake-like something-or-
  3474. other. Neato. But we want to model something useful, something
  3475. that we might see in real life. How about a chain?
  3476.  
  3477. Thinking about it for a moment, we realize that a single link of
  3478. a chain can be easily modeled using two half tori and two
  3479. cylinders. We create a new file. We can use the same camera,
  3480. background, light source and declared objects and transformations
  3481. as we used in tordemo.pov:
  3482.  
  3483.   #include "colors.inc"
  3484.   camera {
  3485.     location <0, .1, -25>
  3486.     look_at 0
  3487.     angle 30
  3488.   }
  3489.   background { color Gray50 }
  3490.   light_source{ <300, 300, -1000> White }
  3491.   #declare Half_Torus = difference {
  3492.     torus { 4,1
  3493.       sturm
  3494.       rotate x*-90  // so we can see it from the top
  3495.     }
  3496.     box { <-5, -5, -1>, <5, 0, 1> }
  3497.     pigment { Green }
  3498.   }
  3499.   #declare Flip_It_Over = x*180;
  3500.   #declare Torus_Translate = 8;
  3501. Now, we make a complete torus of two half tori:
  3502.  
  3503.   union {
  3504.     object { Half_Torus }
  3505.     object { Half_Torus rotate Flip_It_Over }
  3506.   }
  3507. This may seem like a wasteful way to make a complete torus, but
  3508. we are really going to move each half apart to make room for the
  3509. cylinders. First, we add the declared cylinder before the union:
  3510.  
  3511.   #declare Chain_Segment = cylinder { <0, 4, 0>, <0, -4, 0>, 1
  3512.     pigment { Green }
  3513.   }
  3514. We then add two Chain_Segments to the union and translate them so
  3515. that they line up with the minor radius of the torus on each
  3516. side:
  3517.  
  3518.   union {
  3519.     object { Half_Torus }
  3520.     object { Half_Torus rotate Flip_It_Over }
  3521.     object { Chain_Segment translate  x*Torus_Translate/2 }
  3522.     object { Chain_Segment translate -x*Torus_Translate/2 }
  3523.   }
  3524. Now we translate the two half tori +y and -y so that the clipped
  3525. ends meet the ends of the cylinders. This distance is equal to
  3526. half of the previously declared Torus_Translate:
  3527.  
  3528.   union {
  3529.     object { Half_Torus
  3530.       translate y*Torus_Translate/2
  3531.     }
  3532.     object { Half_Torus
  3533.       rotate Flip_It_Over
  3534.       translate -y*Torus_Translate/2
  3535.     }
  3536.     object { Chain_Segment
  3537.       translate x*Torus_Translate/2
  3538.     }
  3539.     object { Chain_Segment
  3540.       translate -x*Torus_Translate/2
  3541.     }
  3542.   }
  3543. We render this and viola! A single link of a chain. But we aren't
  3544. done yet! Whoever heard of a green chain? We would rather use a
  3545. nice metallic color instead. First, we remove any pigment blocks
  3546. in the declared torsos and cylinders. Then we add the following
  3547. before the union:
  3548.  
  3549.   #declare Chain_Gold = texture {
  3550.     pigment { BrightGold }
  3551.     finish {
  3552.       ambient .1
  3553.       diffuse .4
  3554.       reflection .25
  3555.       specular 1
  3556.       metallic
  3557.     }
  3558.   }
  3559. We then add the texture to the union and declare the union as a
  3560. single link:
  3561.  
  3562.   #declare Link = union {
  3563.     object { Half_Torus
  3564.       translate y*Torus_Translate/2
  3565.     }
  3566.     object { Half_Torus
  3567.       rotate Flip_It_Over
  3568.       translate -y*Torus_Translate/2
  3569.     }
  3570.     object { Chain_Segment
  3571.       translate x*Torus_Translate/2
  3572.     }
  3573.     object { Chain_Segment
  3574.       translate -x*Torus_Translate/2
  3575.     }
  3576.     texture { Chain_Gold }
  3577.   }
  3578. Now we make a union of two links. The second one will have to be
  3579. translated +y so that its inner wall just meets the inner wall of
  3580. the other link, just like the links of a chain. This distance
  3581. turns out to be double the previously declared Torus_Translate
  3582. minus 2 (twice the minor radius). This can be described by the
  3583. expression:
  3584.  
  3585.   Torus_Translate*2-2*y
  3586. We declare this expression as follows:
  3587.  
  3588.   #declare Link_Translate = Torus_Translate*2-2*y;
  3589. In the object block, we will use this declared value so that we
  3590. can multiply it to create other links. Now, we rotate the second
  3591. link 90*y so that it is perpendicular to the first, just like
  3592. links of a chain. Finally, we scale the union by 1/4 so that we
  3593. can see the whole thing:
  3594.  
  3595.   union {
  3596.     object { Link }
  3597.     object { Link translate y*Link_Translate rotate y*90 }
  3598.     scale .25
  3599.   }
  3600. We render this and we will see a very realistic pair of links. If
  3601. we want to make an entire chain, we must declare the above union
  3602. and then create another union of this declared object. We must be
  3603. sure to remove the scaling from the declared object:
  3604.  
  3605.   #declare Link_Pair =
  3606.   union {
  3607.     object { Link }
  3608.     object { Link translate y*Link_Translate rotate y*90 }
  3609.   }
  3610. Now we declare our chain:
  3611.  
  3612.   #declare Chain = union {
  3613.     object { Link_Pair}
  3614.     object { Link_Pair translate  y*Link_Translate*2 }
  3615.     object { Link_Pair translate  y*Link_Translate*4 }
  3616.     object { Link_Pair translate  y*Link_Translate*6 }
  3617.     object { Link_Pair translate -y*Link_Translate*2 }
  3618.     object { Link_Pair translate -y*Link_Translate*4 }
  3619.     object { Link_Pair translate -y*Link_Translate*6 }
  3620.   }
  3621. And finally we create our chain with a couple of transformations
  3622. to make it easier to see. These include scaling it down by a
  3623. factor of 1/10, and rotating it so that we can clearly see each
  3624. link:
  3625.  
  3626.   object { Chain scale .1 rotate <0, 45, -45> }
  3627.                                 
  3628.          The torus object can be used to create chains.
  3629. We render this and we should see a very realistic gold chain
  3630. stretched diagonally across the screen.
  3631.  
  3632.  
  3633. 2.5  The Light Source
  3634. In any ray-traced scene, the light needed to illuminate our
  3635. objects and their surfaces must come from a light source. There
  3636. are many kinds of light sources available in POV-Ray and careful
  3637. use of the correct kind can yield very impressive results. Let's
  3638. take a moment to explore some of the different kinds of light
  3639. sources and their various parameters.
  3640.  
  3641.  
  3642. 2.5.1     The Pointlight Source
  3643. Pointlights are exactly what the name indicates. A pointlight has
  3644. no size, is invisible and illuminates everything in the scene
  3645. equally no matter how far away from the light source it may be
  3646. (this behavior can be changed). This is the simplest and most
  3647. basic light source. There are only two important parameters,
  3648. location and color. Let's design a simple scene and place a
  3649. pointlight source in it.
  3650.  
  3651. We create a new file and name it litedemo.pov. We edit it as
  3652. follows:
  3653.  
  3654.   #include "colors.inc"
  3655.   #include "textures.inc"
  3656.   camera {
  3657.     location  <-4, 3, -9>
  3658.     look_at   <0, 0, 0>
  3659.     angle 48
  3660.   }
  3661. We add the following simple objects:
  3662.  
  3663.   plane { y, -1
  3664.     texture {
  3665.       pigment {
  3666.         checker
  3667.         color rgb<0.5, 0, 0>
  3668.         color rgb<0, 0.5, 0.5>
  3669.       }
  3670.       finish {
  3671.         diffuse 0.4
  3672.         ambient 0.2
  3673.         phong 1
  3674.         phong_size 100
  3675.         reflection 0.25
  3676.       }
  3677.     }
  3678.   }
  3679.   torus { 1.5, 0.5
  3680.     texture { Brown_Agate }
  3681.     rotate <90, 160, 0>
  3682.     translate  <-1, 1, 3>
  3683.   }
  3684.   box { <-1, -1, -1>, <1, 1, 1>
  3685.     texture { DMFLightOak }
  3686.     translate  <2, 0, 2.3>
  3687.   }
  3688.   cone { <0,1,0>, 0, <0,0,0>, 1
  3689.     texture { PinkAlabaster }
  3690.     scale <1, 3, 1>
  3691.     translate  <-2, -1, -1>
  3692.   }
  3693.   sphere { <0,0,0>,1
  3694.     texture { Sapphire_Agate }
  3695.     translate  <1.5, 0, -2>
  3696.   }
  3697. Now we add a pointlight:
  3698.  
  3699.   light_source {
  3700.     <2, 10, -3>
  3701.     color White
  3702.   }
  3703. We render this at 200x150 -A and see that the objects are clearly
  3704. visible with sharp shadows. The sides of curved objects nearest
  3705. the light source are brightest in color with the areas that are
  3706. facing away from the light source being darkest. We also note
  3707. that the checkered plane is illuminated evenly all the way to the
  3708. horizon. This allows us to see the plane, but it is not very
  3709. realistic.
  3710.  
  3711.  
  3712. 2.5.2     The Spotlight Source
  3713. Spotlights are a very useful type of light source. They can be
  3714. used to add highlights and illuminate features much as a
  3715. photographer uses spots to do the same thing. To create a
  3716. spotlight simply add the spotlight keyword to a regular point
  3717. light.  There are a few more parameters with spotlights than with
  3718. pointlights. These are radius, falloff, tightness and point_at.
  3719. The radius parameter is the angle of the fully illuminated cone.
  3720. The falloff parameter is the angle of the umbra cone where the
  3721. light falls off to darkness. The tightness is a parameter that
  3722. determines the rate of the light falloff. The point_at parameter
  3723. is just what it says, the location where the spotlight is
  3724. pointing to. Let's change the light in our scene as follows:
  3725.  
  3726.   light_source {
  3727.     <0, 10, -3>
  3728.     color White
  3729.     spotlight
  3730.     radius 15
  3731.     falloff 20
  3732.     tightness 10
  3733.     point_at <0, 0, 0>
  3734.   }
  3735. We render this at 200x150 -A and see that only the objects are
  3736. illuminated. The rest of the plane and the outer portions of the
  3737. objects are now unlit. There is a broad falloff area but the
  3738. shadows are still razor sharp. Let's try fiddling with some of
  3739. these parameters to see what they do. We change the falloff value
  3740. to 16 (it must always be larger than the radius value) and render
  3741. again.  Now the falloff is very narrow and the objects are either
  3742. brightly lit or in total darkness. Now we change falloff back to
  3743. 20 and change the tightness value to 100 (higher is tighter) and
  3744. render again. The spotlight appears to have gotten much smaller
  3745. but what has really happened is that the falloff has become so
  3746. steep that the radius actually appears smaller.
  3747.  
  3748. We decide that a tightness value of 10 (the default) and a
  3749. falloff value of 18 are best for this spotlight and we now want
  3750. to put a few spots around the scene for effect. Let's place a
  3751. slightly narrower blue and a red one in addition to the white one
  3752. we already have:
  3753.  
  3754.   light_source {
  3755.     <10, 10, -1>
  3756.     color Red
  3757.     spotlight
  3758.     radius 12
  3759.     falloff 14
  3760.     tightness 10
  3761.     point_at <2, 0, 0>
  3762.   }
  3763.   light_source {
  3764.     <-12, 10, -1>
  3765.     color Blue
  3766.     spotlight
  3767.     radius 12
  3768.     falloff 14
  3769.     tightness 10
  3770.     point_at <-2, 0, 0>
  3771.   }
  3772. Rendering this we see that the scene now has a wonderfully
  3773. mysterious air to it. The three spotlights all converge on the
  3774. objects making them blue on one side and red on the other with
  3775. enough white in the middle to provide a balance.
  3776.  
  3777.  
  3778. 2.5.3     The Cylindrical Light Source
  3779. Spotlights are cone shaped, meaning that their effect will change
  3780. with distance. The farther away from the spotlight an object is,
  3781. the larger the apparent radius will be. But we may want the
  3782. radius and falloff to be a particular size no matter how far away
  3783. the spotlight is. For this reason, cylindrical light sources are
  3784. needed. A cylindrical light source is just like a spotlight,
  3785. except that the radius and falloff regions are the same no matter
  3786. how far from the light source our object is. The shape is
  3787. therefore a cylinder rather than a cone. We can specify a
  3788. cylindrical light source by replacing the spotlight keyword with
  3789. the cylinder keyword. We try this now with our scene by replacing
  3790. all three spotlights with cylinder lights and rendering again. We
  3791. see that the scene is much dimmer. This is because the
  3792. cylindrical constraints do not let the light spread out like in a
  3793. spotlight. Larger radius and falloff values are needed to do the
  3794. job. We try a radius of 20 and a falloff of 30 for all three
  3795. lights. That's the ticket!
  3796.  
  3797.  
  3798. 2.5.4     The Area Light Source
  3799. So far all of our light sources have one thing in common. They
  3800. produce sharp shadows. This is because the actual light source is
  3801. a point that is infinitely small. Objects are either in direct
  3802. sight of the light, in which case they are fully illuminated, or
  3803. they are not, in which case they are fully shaded. In real life,
  3804. this kind of stark light and shadow situation exists only in
  3805. outer space where the direct light of the sun pierces the total
  3806. blackness of space. But here on Earth, light bends around
  3807. objects, bounces off objects, and usually the source has some
  3808. dimension, meaning that it can be partially hidden from sight
  3809. (shadows are not sharp anymore). They have what is known as an
  3810. umbra, or an area of fuzziness where there is neither total light
  3811. or shade. In order to simulate these soft shadows, a ray-tracer
  3812. must give its light sources dimension. POV-Ray accomplishes this
  3813. with a feature known as an area light.
  3814.  
  3815. Area lights have dimension in two axis'. These are specified by
  3816. the first two vectors in the area light syntax. We must also
  3817. specify how many lights are to be in the array. More will give us
  3818. cleaner soft shadows but will take longer to render. Usually a
  3819. 3*3 or a 5*5 array will suffice. We also have the option of
  3820. specifying an adaptive value. The adaptive keyword tells the ray-
  3821. tracer that it can adapt to the situation and send only the
  3822. needed rays to determine the value of the pixel. If adaptive is
  3823. not used, a separate ray will be sent for every light in the area
  3824. light.  This can really slow things down. The higher the adaptive
  3825. value the cleaner the umbra will be but the longer the trace will
  3826. take.  Usually an adaptive value of 1 is sufficient. Finally, we
  3827. probably should use the jitter keyword.  This tells the ray-
  3828. tracer to slightly move the position of each light in the area
  3829. light so that the shadows appear truly soft instead of giving us
  3830. an umbra consisting of closely banded shadows.
  3831.  
  3832. OK, let's try one. We comment out the cylinder lights and add the
  3833. following:
  3834.  
  3835.   light_source {
  3836.     <2, 10, -3>
  3837.     color White
  3838.     area_light <5, 0, 0>, <0, 0, 5>, 5, 5
  3839.     adaptive 1
  3840.     jitter
  3841.   }
  3842. This is a white area light centered at <2,10,-3>. It is 5 units
  3843. (along the x-axis) by 5 units (along the z-axis) in size and has
  3844. 25 (5*5) lights in it. We have specified adaptive 1 and jitter.
  3845. We render this at 200x150 -A.
  3846.  
  3847. Right away we notice two things. The trace takes quite a bit
  3848. longer than it did with a point or a spotlight and the shadows
  3849. are no longer sharp! They all have nice soft umbrae around them.
  3850. Wait, it gets better.
  3851.  
  3852. Spotlights and cylinder lights can be area lights too! Remember
  3853. those sharp shadows from the spotlights in our scene? It would
  3854. not make much sense to use a 5*5 array for a spotlight, but a
  3855. smaller array might do a good job of giving us just the right
  3856. amount of umbra for a spotlight.  Let's try it. We comment out
  3857. the area light and change the cylinder lights so that they read
  3858. as follows:
  3859.  
  3860.   light_source {
  3861.     <2, 10, -3>
  3862.     color White
  3863.     spotlight
  3864.     radius 15
  3865.     falloff 18
  3866.     tightness 10
  3867.     area_light <1, 0, 0>, <0, 0, 1>, 2, 2
  3868.     adaptive 1
  3869.     jitter
  3870.     point_at <0, 0, 0>
  3871.   }
  3872.   light_source {
  3873.     <10, 10, -1>
  3874.     color Red
  3875.     spotlight
  3876.     radius 12
  3877.     falloff 14
  3878.     tightness 10
  3879.     area_light <1, 0, 0>, <0, 0, 1>, 2, 2
  3880.     adaptive 1
  3881.     jitter
  3882.     point_at <2, 0, 0>
  3883.   }
  3884.   light_source {
  3885.     <-12, 10, -1>
  3886.     color Blue
  3887.     spotlight
  3888.     radius 12
  3889.     falloff 14
  3890.     tightness 10
  3891.     area_light <1, 0, 0>, <0, 0, 1>, 2, 2
  3892.     adaptive 1
  3893.     jitter
  3894.     point_at <-2, 0, 0>
  3895.   }
  3896. We now have three area-spotlights, one unit square consisting of
  3897. an array of four (2*2) lights, three different colors, all
  3898. shining on our scene. We render this at 200x150 -A. It appears to
  3899. work perfectly. All our shadows have small, tight umbrae, just
  3900. the sort we would expect to find on an object under a real
  3901. spotlight.
  3902.  
  3903.  
  3904. 2.5.5     The Ambient Light Source
  3905. The ambient light source is used to simulate the effect of inter-
  3906. diffuse reflection. If there wasn't inter-diffuse reflection all
  3907. areas not directly lit by a light source would be completely
  3908. dark. POV-Ray uses the ambient keyword to determine how much
  3909. light coming from the ambient light source is reflected by a
  3910. surface.
  3911.  
  3912. By default the ambient light source, which emits its light
  3913. everywhere and in all directions, is pure white (rgb <1,1,1>).
  3914. Changing its color can be used to create interesting effects.
  3915. First of all the overall light level of the scene can be adjusted
  3916. easily. Instead of changing all ambient values in every finish
  3917. only the ambient light source is modified. By assigning different
  3918. colors we can create nice effects like a moody reddish ambient
  3919. lighting. For more details about the ambient light source see
  3920. "Ambient Light".
  3921.  
  3922. Below is an example of a red ambient light source.
  3923.  
  3924.   global_settings { ambient_light rgb<1, 0, 0> }
  3925.  
  3926. 2.5.6     Light Source Specials
  3927.  
  3928. 2.5.6.1   Using Shadowless Lights
  3929. Light sources can be assigned the shadowless keyword and no
  3930. shadows will be cast due to its presence in a scene. Sometimes,
  3931. scenes are difficult to illuminate properly using the lights we
  3932. have chosen to illuminate our objects.  It is impractical and
  3933. unrealistic to apply a higher ambient value to the texture of
  3934. every object in the scene. So instead, we would place a couple of
  3935. fill lights around the scene. Fill lights are simply dimmer
  3936. lights with the shadowless keyword that act to boost the
  3937. illumination of other areas of the scene that may not be lit
  3938. well.  Let's try using one in our scene.
  3939.  
  3940. Remember the three colored area spotlights? We go back and un-
  3941. comment them and comment out any other lights we have made. Now
  3942. we add the following:
  3943.  
  3944.   light_source {
  3945.     <0, 20, 0>
  3946.     color Gray50
  3947.     shadowless
  3948.   }
  3949. This is a fairly dim light 20 units over the center of the scene.
  3950. It will give a dim illumination to all objects including the
  3951. plane in the background. We render it and see.
  3952.  
  3953.  
  3954. 2.5.6.2   Assigning an Object to a Light Source
  3955. Light sources are invisible. They are just a location where the
  3956. light appears to be coming from. They have no true size or shape.
  3957. If we want our light source to be a visible shape, we can use the
  3958. looks_like keyword. We can specify that our light source can look
  3959. like any object we choose. When we use looks_like, then no_shadow
  3960. is applied to the object automatically. This is done so that the
  3961. object will not block any illumination from the light source.  If
  3962. we want some blocking to occur (as in a lampshade), it is better
  3963. to simply use a union to do the same thing. Let's add such an
  3964. object to our scene. Here is a light bulb we have made just for
  3965. this purpose:
  3966.  
  3967.   #declare Lightbulb = union {
  3968.     merge {
  3969.       sphere { <0,0,0>,1 }
  3970.       cylinder { <0,0,1>, <0,0,0>, 1
  3971.         scale <0.35, 0.35, 1.0>
  3972.         translate  0.5*z
  3973.       }
  3974.       texture {
  3975.         pigment {color rgb <1, 1, 1>}
  3976.         finish {ambient .8 diffuse .6}
  3977.       }
  3978.     }
  3979.     cylinder { <0,0,1>, <0,0,0>, 1
  3980.       scale <0.4, 0.4, 0.5>
  3981.       texture { Brass_Texture }
  3982.       translate  1.5*z
  3983.     }
  3984.     rotate -90*x
  3985.     scale .5
  3986.   }
  3987. Now we add the light source:
  3988.  
  3989.   light_source {
  3990.     <0, 2, 0>
  3991.     color White
  3992.     looks_like { Lightbulb }
  3993.   }
  3994. Rendering this we see that a fairly believable light bulb now
  3995. illuminates the scene. However, if we do not specify a high
  3996. ambient value, the light bulb is not lit by the light source. On
  3997. the plus side, all of the shadows fall away from the light bulb,
  3998. just as they would in a real situation. The shadows are sharp, so
  3999. let's make our bulb an area light:
  4000.  
  4001.   light_source {
  4002.     <0, 2, 0>
  4003.     color White
  4004.     area_light <1, 0, 0>, <0, 1, 0>, 2, 2
  4005.     adaptive 1
  4006.     jitter
  4007.     looks_like { Lightbulb }
  4008.   }
  4009. We note that we have placed this area light in the x-y-plane
  4010. instead of the x-z-plane. We also note that the actual appearance
  4011. of the light bulb is not affected in any way by the light source.
  4012. The bulb must be illuminated by some other light source or by, as
  4013. in this case, a high ambient value.
  4014.  
  4015.  
  4016. 2.5.6.3   Using Light Fading
  4017. If it is realism we want, it is not realistic for the plane to be
  4018. evenly illuminated off into the distance. In real life, light
  4019. gets scattered as it travels so it diminishes its ability to
  4020. illuminate objects the farther it gets from its source. To
  4021. simulate this, POV-Ray allows us to use two keywords:
  4022. fade_distance, which specifies the distance at which full
  4023. illumination is achieved, and fade_power, an exponential value
  4024. which determines the actual rate of attenuation. Let's apply
  4025. these keywords to our fill light.
  4026.  
  4027. First, we make the fill light a little brighter by changing
  4028. Gray50 to Gray75. Now we change that fill light as follows:
  4029.  
  4030.   light_source {
  4031.     <0, 20, 0>
  4032.     color Gray75
  4033.     fade_distance 5
  4034.     fade_power 1
  4035.     shadowless
  4036.   }
  4037. This means that the full value of the fill light will be achieved
  4038. at a distance of 5 units away from the light source. The fade
  4039. power of 1 means that the falloff will be linear (the light falls
  4040. of at a constant rate). We render this to see the result.
  4041.  
  4042. That definitely worked!  Now let's try a fade power of 2 and a
  4043. fade distance of 10. Again, this works well. The falloff is much
  4044. faster with a fade power of 2 so we had to raise the fade
  4045. distance to 10.
  4046.  
  4047.  
  4048. 2.6  Simple Texture Options
  4049. The pictures rendered so far where somewhat boring regarding the
  4050. appearance of the objects. Let's add some fancy features to the
  4051. texture.
  4052.  
  4053.  
  4054. 2.6.1     Surface Finishes
  4055. One of the main features of a ray-tracer is its ability to do
  4056. interesting things with surface finishes such as highlights and
  4057. reflection. Let's add a nice little Phong highlight (shiny spot)
  4058. to a sphere. To do this we need to add a finish keyword followed
  4059. by a parameter. We change the definition of the sphere to this:
  4060.  
  4061.   sphere { <0, 1, 2>, 2
  4062.     texture {
  4063.       pigment { color Yellow } // Yellow is pre-defined in
  4064. COLORS.INC
  4065.       finish { phong 1 }
  4066.     }
  4067.   }
  4068. We render the scene. The phong keyword adds a highlight the same
  4069. color of the light shining on the object. It adds a lot of
  4070. credibility to the picture and makes the object look smooth and
  4071. shiny. Lower values of phong will make the highlight less bright
  4072. (values should be between 0 and 1).
  4073.  
  4074.  
  4075. 2.6.2     Adding Bumpiness
  4076. The highlight we have added illustrates how much of our
  4077. perception depends on the reflective properties of an object. Ray-
  4078. tracing can exploit this by playing tricks on our perception to
  4079. make us see complex details that aren't really there.
  4080.  
  4081. Suppose we wanted a very bumpy surface on the object. It would be
  4082. very difficult to mathematically model lots of bumps. We can
  4083. however simulate the way bumps look by altering the way light
  4084. reflects off of the surface. Reflection calculations depend on a
  4085. vector called a surface normal. This is a vector which points
  4086. away from the surface and is perpendicular to it. By artificially
  4087. modifying (or perturbing) this normal vector we can simulate
  4088. bumps. We change the scene to read as follows and render it:
  4089.  
  4090.   sphere { <0, 1, 2>, 2
  4091.     texture {
  4092.       pigment { color Yellow }
  4093.       normal { bumps 0.4 scale 0.2 }
  4094.       finish { phong 1}
  4095.     }
  4096.   }
  4097. This tells POV-Ray to use the bumps pattern to modify the surface
  4098. normal. The value 0.4 controls the apparent depth of the bumps.
  4099. Usually the bumps are about 1 unit wide which doesn't work very
  4100. well with a sphere of radius 2. The scale makes the bumps 1/5th
  4101. as wide but does not affect their depth.
  4102.  
  4103.  
  4104. 2.6.3     Creating Color Patterns
  4105. We can do more than assigning a solid color to an object. We can
  4106. create complex patterns in the pigment block like in this
  4107. example:
  4108.  
  4109.   sphere { <0, 1, 2>, 2
  4110.     texture {
  4111.       pigment {
  4112.         wood
  4113.         color_map {
  4114.           [0.0 color DarkTan]
  4115.           [0.9 color DarkBrown]
  4116.           [1.0 color VeryDarkBrown]
  4117.         }
  4118.         turbulence 0.05
  4119.         scale <0.2, 0.3, 1>
  4120.       }
  4121.       finish { phong 1 }
  4122.     }
  4123.   }
  4124. The keyword wood specifies a pigment pattern of concentric rings
  4125. like rings in wood. The color_map keyword specifies that the
  4126. color of the wood should blend from DarkTan to DarkBrown over the
  4127. first 90% of the vein and from DarkBrown to VeryDarkBrown over
  4128. the remaining 10%. The turbulence keyword slightly stirs up the
  4129. pattern so the veins aren't perfect circles and the scale keyword
  4130. adjusts the size of the pattern.
  4131.  
  4132. Most patterns are set up by default to give us one feature across
  4133. a sphere of radius 1.0. A feature is very roughly defined as a
  4134. color transition. For example, a wood texture would have one band
  4135. on a sphere of radius 1.0. In this example we scale the pattern
  4136. using the scale keyword followed by a vector. In this case we
  4137. scaled 0.2 in the x direction, 0.3 in the y direction and the z
  4138. direction is scaled by 1, which leaves it unchanged. Scale values
  4139. larger than one will stretch an element. Scale values smaller
  4140. than one will squish an element. A scale value of one will leave
  4141. an element unchanged.
  4142.  
  4143.  
  4144. 2.6.4     Pre-defined Textures
  4145. POV-Ray has some very sophisticated textures pre-defined in the
  4146. standard include files glass.inc, metals.inc, stones.inc and
  4147. woods.inc. Some are entire textures with pigment, normal and/or
  4148. finish parameters already defined. Some are just pigments or just
  4149. finishes.  We change the definition of our sphere to the
  4150. following and then re-render it:
  4151.  
  4152.   sphere { <0, 1, 2>, 2
  4153.     texture {
  4154.       pigment {
  4155.         DMFWood4       // pre-defined in textures.inc
  4156.         scale 4        // scale by the same amount in all
  4157.                        // directions
  4158.       }
  4159.       finish { Shiny } // pre-defined in finish.inc
  4160.     }
  4161.   }
  4162. The pigment identifier DMFWood4 has already been scaled down
  4163. quite small when it was defined. For this example we want to
  4164. scale the pattern larger. Because we want to scale it uniformly
  4165. we can put a single value after the scale keyword rather than a
  4166. vector of x, y, z scale factors.
  4167.  
  4168. We look through the file textures.inc to see what pigments and
  4169. finishes are defined and try them out. We just insert the name of
  4170. the new pigment where DMFWood4 is now or try a different finish
  4171. in place of Shiny and re-render our file.
  4172.  
  4173. Here is an example of using a complete texture identifier rather
  4174. than just the pieces.
  4175.  
  4176.   sphere { <0, 1, 2>, 2
  4177.     texture { PinkAlabaster }
  4178.   }
  4179.  
  4180. 2.7  Advanced Texture Options
  4181. The extremely powerful texturing ability is one thing that really
  4182. sets POV-Ray apart from other raytracers. So far we have not
  4183. really tried anything too complex but by now we should be
  4184. comfortable enough with the program's syntax to try some of the
  4185. more advanced texture options.
  4186.  
  4187. Obviously, we cannot try them all. It would take a tutorial a lot
  4188. more pages to use every texturing option available in POV-Ray.
  4189. For this limited tutorial, we will content ourselves to just
  4190. trying a few of them to give an idea of how textures are created.
  4191. With a little practice, we will soon be creating beautiful
  4192. textures of our own.
  4193.  
  4194. Note that early versions of POV-Ray made a distinction between
  4195. pigment and normal patterns, i. e. patterns that could be used
  4196. inside a normal or pigment statement. With POV-Ray 3.0 this
  4197. restriction was removed so that all patterns listed in section
  4198. "Patterns" can be used as a pigment or normal pattern.
  4199.  
  4200.  
  4201. 2.7.1     Pigments
  4202. Every surface must have a color. In POV-Ray this color is called
  4203. a pigment. It does not have to be a single color. It can be a
  4204. color pattern, a color list or even an image map. Pigments can
  4205. also be layered one on top of the next so long as the uppermost
  4206. layers are at least partially transparent so the ones beneath can
  4207. show through. Let's play around with some of these kinds of
  4208. pigments.
  4209.  
  4210. We create a file called texdemo.pov and edit it as follows:
  4211.  
  4212.   #include "colors.inc"
  4213.   camera {
  4214.     location <1, 1, -7>
  4215.     look_at 0
  4216.     angle 36
  4217.   }
  4218.   light_source { <1000, 1000, -1000> White }
  4219.   plane { y, -1.5
  4220.     pigment { checker Green, White }
  4221.   }
  4222.   sphere { <0,0,0>, 1
  4223.     pigment { Red }
  4224.   }
  4225. Giving this file a quick test render at 200x150 -A we see that it
  4226. is a simple red sphere against a green and white checkered plane.
  4227. We will be using the sphere for our textures.
  4228.  
  4229.  
  4230. 2.7.1.1   Using Color List Pigments
  4231. Before we begin we should note that we have already made one kind
  4232. of pigment, the color list pigment. In the previous example we
  4233. have used a checkered pattern on our plane. There are two other
  4234. kinds of color list pigments, brick and hexagon. Let's quickly
  4235. try each of these. First, we change the plane's pigment as
  4236. follows:
  4237.  
  4238.   pigment { hexagon Green, White, Yellow }
  4239. Rendering this we see a three-color hexagonal pattern. Note that
  4240. this pattern requires three colors. Now we change the pigment
  4241. to...
  4242.  
  4243.   pigment { brick Gray75, Red rotate -90*x scale .25 }
  4244. Looking at the resulting image we see that the plane now has a
  4245. brick pattern. We note that we had to rotate the pattern to make
  4246. it appear correctly on the flat plane. This pattern normally is
  4247. meant to be used on vertical surfaces. We also had to scale the
  4248. pattern down a bit so we could see it more easily. We can play
  4249. around with these color list pigments, change the colors, etc.
  4250. until we get a floor that we like.
  4251.  
  4252.  
  4253. 2.7.1.2   Using Pigment and Patterns
  4254. Let's begin texturing our sphere by using a pattern and a color
  4255. map consisting of three colors. We replace the pigment block with
  4256. the following.
  4257.  
  4258.   pigment {
  4259.     gradient x
  4260.     color_map {
  4261.       [0.00 color Red]
  4262.       [0.33 color Blue]
  4263.       [0.66 color Yellow]
  4264.       [1.00 color Red]
  4265.     }
  4266.   }
  4267. Rendering this we see that the gradient pattern gives us an
  4268. interesting pattern of vertical stripes. We change the gradient
  4269. direction to y. The stripes are horizontal now. We change the
  4270. gradient direction to z. The stripes are now more like concentric
  4271. rings. This is because the gradient direction is directly away
  4272. from the camera. We change the direction back to x and add the
  4273. following to the pigment block.
  4274.  
  4275.   pigment {
  4276.     gradient x
  4277.     color_map {
  4278.       [0.00 color Red]
  4279.       [0.33 color Blue]
  4280.       [0.66 color Yellow]
  4281.       [1.00 color Red]
  4282.     }
  4283.     rotate -45*z          // <- add this line
  4284.   }
  4285. The vertical bars are now slanted at a 45 degree angle. All
  4286. patterns can be rotated, scaled and translated in this manner.
  4287. Let's now try some different types of patterns. One at a time, we
  4288. substitute the following keywords for gradient x and render to
  4289. see the result: bozo, marble, agate, granite, leopard, spotted
  4290. and wood (if we like we can test all patterns listed in section
  4291. "Patterns").
  4292.  
  4293. Rendering these we see that each results in a slightly different
  4294. pattern. But to get really good results each type of pattern
  4295. requires the use of some pattern modifiers.
  4296.  
  4297.  
  4298. 2.7.1.3   Using Pattern Modifiers
  4299. Let's take a look at some pattern modifiers. First, we change the
  4300. pattern type to bozo. Then we add the following change.
  4301.  
  4302.   pigment {
  4303.     bozo
  4304.     frequency 3            // <- add this line
  4305.     color_map {
  4306.       [0.00 color Red]
  4307.       [0.33 color Blue]
  4308.       [0.66 color Yellow]
  4309.       [1.00 color Red]
  4310.     }
  4311.     rotate -45*z
  4312.   }
  4313. The frequency modifier determines the number of times the color
  4314. map repeats itself per unit of size. This change makes the bozo
  4315. pattern we saw earlier have many more bands in it. Now we change
  4316. the pattern type to marble. When we rendered this earlier, we saw
  4317. a banded pattern similar to gradient y that really did not look
  4318. much like marble at all. This is because marble really is a kind
  4319. of gradient and it needs another pattern modifier to look like
  4320. marble. This modifier is called turbulence. We change the line
  4321. frequency 3 to turbulence 1 and render again. That's better! Now
  4322. let's put frequency 3 back in right after the turbulence and take
  4323. another look. Even more interesting!
  4324.  
  4325. But wait, it gets better! Turbulence itself has some modifiers of
  4326. its own. We can adjust the turbulence several ways. First, the
  4327. float that follows the turbulence keyword can be any value with
  4328. higher values giving us more turbulence. Second, we can use the
  4329. keywords omega, lambda and octaves to change the turbulence
  4330. parameters. Let's try this now:
  4331.  
  4332.   pigment {
  4333.     marble
  4334.     turbulence 0.5
  4335.     lambda 1.5
  4336.     omega 0.8
  4337.     octaves 5
  4338.     frequency 3
  4339.     color_map {
  4340.       [0.00 color Red]
  4341.       [0.33 color Blue]
  4342.       [0.66 color Yellow]
  4343.       [1.00 color Red]
  4344.     }
  4345.     rotate 45*z
  4346.   }
  4347. Rendering this we see that the turbulence has changed and the
  4348. pattern looks different. We play around with the numerical values
  4349. of turbulence, lambda, omega and octaves to see what they do.
  4350.  
  4351.  
  4352. 2.7.1.4   Using Transparent Pigments and Layered Textures
  4353. Pigments are described by numerical values that give the rgb
  4354. value of the color to be used (like color rgb<1,0,0> giving us a
  4355. red color). But this syntax will give us more than just the rgb
  4356. values. We can specify filtering transparency by changing it as
  4357. follows: color rgbf<1,0,0,1>. The f stands for filter, POV-Ray's
  4358. word for filtered transparency. A value of one means that the
  4359. color is completely transparent, but still filters the light
  4360. according to what the pigment is. In this case, the color will be
  4361. a transparent red, like red cellophane.
  4362.  
  4363. There is another kind of transparency in POV-Ray. It is called
  4364. transmittance or non-filtering transparency (the keyword is
  4365. transmit). It is different from filter in that it does not filter
  4366. the light according to the pigment color. It instead allows all
  4367. the light to pass through unchanged. It can be specified like
  4368. this: rgbt <1,0,0,1>.
  4369.  
  4370. Let's use some transparent pigments to create another kind of
  4371. texture, the layered texture. Returning to our previous example,
  4372. declare the following texture.
  4373.  
  4374.   #declare LandArea = texture {
  4375.       pigment {
  4376.         agate
  4377.         turbulence 1
  4378.         lambda 1.5
  4379.         omega .8
  4380.         octaves 8
  4381.         color_map {
  4382.           [0.00 color rgb <.5, .25, .15>]
  4383.           [0.33 color rgb <.1, .5, .4>]
  4384.           [0.86 color rgb <.6, .3, .1>]
  4385.           [1.00 color rgb <.5, .25, .15>]
  4386.         }
  4387.       }
  4388.     }
  4389. This texture will be the land area. Now let's make the oceans by
  4390. declaring the following.
  4391.  
  4392.   #declare OceanArea = texture {
  4393.       pigment {
  4394.         bozo
  4395.         turbulence .5
  4396.         lambda 2
  4397.         color_map {
  4398.           [0.00, 0.33 color rgb <0, 0, 1>
  4399.                       color rgb <0, 0, 1>]
  4400.           [0.33, 0.66 color rgbf <1, 1, 1, 1>
  4401.                       color rgbf <1, 1, 1, 1>]
  4402.           [0.66, 1.00 color rgb <0, 0, 1>
  4403.                       color rgb <0, 0, 1>]
  4404.         }
  4405.       }
  4406.     }
  4407. Note how the ocean is the opaque blue area and the land is the
  4408. clear area which will allow the underlying texture to show
  4409. through.
  4410.  
  4411. Now, let's declare one more texture to simulate an atmosphere
  4412. with swirling clouds.
  4413.  
  4414.   #declare CloudArea = texture {
  4415.     pigment {
  4416.       agate
  4417.       turbulence 1
  4418.       lambda 2
  4419.       frequency 2
  4420.       color_map {
  4421.         [0.0 color rgbf <1, 1, 1, 1>]
  4422.         [0.5 color rgbf <1, 1, 1, .35>]
  4423.         [1.0 color rgbf <1, 1, 1, 1>]
  4424.       }
  4425.     }
  4426.   }
  4427. Now apply all of these to our sphere.
  4428.  
  4429.   sphere { <0,0,0>, 1
  4430.     texture { LandArea }
  4431.     texture { OceanArea }
  4432.     texture { CloudArea }
  4433.   }
  4434. We render this and have a pretty good rendition of a little
  4435. planetoid. But it could be better. We don't particularly like the
  4436. appearance of the clouds. There is a way they could be done that
  4437. would be much more realistic.
  4438.  
  4439.  
  4440. 2.7.1.5   Using Pigment Maps
  4441. Pigments may be blended together in the same way as the colors in
  4442. a color map using the same pattern keywords and a pigment_map.
  4443. Let's just give it a try.
  4444.  
  4445. We add the following declarations, making sure they appear before
  4446. the other declarations in the file.
  4447.  
  4448.   #declare Clouds1 = pigment {
  4449.       bozo
  4450.       turbulence 1
  4451.       color_map {
  4452.         [0.0 color White filter 1]
  4453.         [0.5 color White]
  4454.         [1.0 color White filter 1]
  4455.       }
  4456.     }
  4457.   #declare Clouds2 = pigment {
  4458.     agate
  4459.     turbulence 1
  4460.     color_map {
  4461.       [0.0 color White filter 1]
  4462.       [0.5 color White]
  4463.       [1.0 color White filter 1]
  4464.       }
  4465.     }
  4466.   #declare Clouds3 = pigment {
  4467.     marble
  4468.     turbulence 1
  4469.     color_map {
  4470.       [0.0 color White filter 1]
  4471.       [0.5 color White]
  4472.       [1.0 color White filter 1]
  4473.     }
  4474.   }
  4475.   #declare Clouds4 = pigment {
  4476.     granite
  4477.     turbulence 1
  4478.     color_map {
  4479.       [0.0 color White filter 1]
  4480.       [0.5 color White]
  4481.       [1.0 color White filter 1]
  4482.     }
  4483.   }
  4484. Now we use these declared pigments in our cloud layer on our
  4485. planetoid. We replace the declared cloud layer with.
  4486.  
  4487.   #declare CloudArea = texture {
  4488.     pigment {
  4489.       gradient y
  4490.       pigment_map {
  4491.         [0.00 Clouds1]
  4492.         [0.25 Clouds2]
  4493.         [0.50 Clouds3]
  4494.         [0.75 Clouds4]
  4495.         [1.00 Clouds1]
  4496.       }
  4497.     }
  4498.   }
  4499. We render this and see a remarkable pattern that looks very much
  4500. like weather patterns on the planet earth. They are separated
  4501. into bands, simulating the different weather types found at
  4502. different latitudes.
  4503.  
  4504.  
  4505. 2.7.2     Normals
  4506. Objects in POV-Ray have very smooth surfaces. This is not very
  4507. realistic so there are several ways to disturb the smoothness of
  4508. an object by perturbing the surface normal. The surface normal is
  4509. the vector that is perpendicular to the angle of the surface. By
  4510. changing this normal the surface can be made to appear bumpy,
  4511. wrinkled or any of the many patterns available. Let's try a
  4512. couple of them.
  4513.  
  4514.  
  4515. 2.7.2.1   Using Basic Normal Modifiers
  4516. We comment out the planetoid sphere for now and, at the bottom of
  4517. the file, create a new sphere with a simple, single color
  4518. texture.
  4519.  
  4520.   sphere { <0,0,0>, 1
  4521.     pigment { Gray75 }
  4522.     normal { bumps 1 scale .2 }
  4523.   }
  4524. Here we have added a normal block in addition to the pigment
  4525. block (note that these do not have to be included in a texture
  4526. block unless they need to be transformed together or need to be
  4527. part of a layered texture). We render this to see what it looks
  4528. like. Now, one at a time, we substitute for the keyword bumps the
  4529. following keywords: dents, wrinkles, ripples and waves (we can
  4530. also use any of the patterns listed in "Patterns"). We render
  4531. each to see what they look like. We play around with the float
  4532. value that follows the keyword. We also experiment with the scale
  4533. value.
  4534.  
  4535. For added interest, we change the plane texture to a single color
  4536. with a normal as follows.
  4537.  
  4538.   plane { y, -1.5
  4539.     pigment { color rgb <.65, .45, .35> }
  4540.     normal { dents .75 scale .25 }
  4541.   }
  4542.  
  4543. 2.7.2.2   Blending Normals
  4544. Normals can be layered similar to pigments but the results can be
  4545. unexpected. Let's try that now by editing the sphere as follows.
  4546.  
  4547.   sphere { <0,0,0>, 1
  4548.     pigment { Gray75 }
  4549.       normal { radial frequency 10 }
  4550.       normal { gradient y scale .2 }
  4551.   }
  4552. As we can see, the resulting pattern is neither a radial nor a
  4553. gradient. It is instead the result of first calculating a radial
  4554. pattern and then calculating a gradient pattern. The results are
  4555. simply additive. This can be difficult to control so POV-Ray
  4556. gives the user other ways to blend normals.
  4557.  
  4558. One way is to use normal maps. A normal map works the same way as
  4559. the pigment map we used earlier. Let's change our sphere texture
  4560. as follows.
  4561.  
  4562.   sphere { <0,0,0>, 1
  4563.     pigment { Gray75 }
  4564.     normal {
  4565.       gradient y
  4566.       frequency 3
  4567.       turbulence .5
  4568.       normal_map {
  4569.         [0.00 granite]
  4570.         [0.25 spotted turbulence .35]
  4571.         [0.50 marble turbulence .5]
  4572.         [0.75 bozo turbulence .25]
  4573.         [1.00 granite]
  4574.       }
  4575.     }
  4576.   }
  4577. Rendering this we see that the sphere now has a very irregular
  4578. bumpy surface. The gradient pattern type separates the normals
  4579. into bands but they are turbulated, giving the surface a chaotic
  4580. appearance. But this give us an idea.
  4581.  
  4582. Suppose we use the same pattern for a normal map that we used to
  4583. create the oceans on our planetoid and applied it to the land
  4584. areas. Does it follow that if we use the same pattern and
  4585. modifiers on a sphere the same size that the shape of the pattern
  4586. would be the same? Wouldn't that make the land areas bumpy while
  4587. leaving the oceans smooth? Let's try it. First, let's render the
  4588. two spheres side-by-side so we can see if the pattern is indeed
  4589. the same. We un-comment the planetoid sphere and make the
  4590. following changes.
  4591.  
  4592.   sphere { <0,0,0>, 1
  4593.     texture { LandArea }
  4594.     texture { OceanArea }
  4595.     //texture { CloudArea }  // <-comment this out
  4596.     translate -x             // <- add this transformation
  4597.   }
  4598. Now we change the gray sphere as follows.
  4599.  
  4600.   sphere { <0,0,0>, 1
  4601.     pigment { Gray75 }
  4602.     normal {
  4603.       bozo
  4604.       turbulence .5
  4605.       lambda 2
  4606.       normal_map {
  4607.         [0.4 dents .15 scale .01]
  4608.         [0.6 agate turbulence 1]
  4609.         [1.0 dents .15 scale .01]
  4610.       }
  4611.     }
  4612.     translate x // <- add this transformation
  4613.   }
  4614. We render this to see if the pattern is the same. We see that
  4615. indeed it is. So let's comment out the gray sphere and add the
  4616. normal block it contains to the land area texture of our
  4617. planetoid. We remove the transformations so that the planetoid is
  4618. centered in the scene again.
  4619.  
  4620.   #declare LandArea = texture {
  4621.     pigment {
  4622.       agate
  4623.       turbulence 1
  4624.       lambda 1.5
  4625.       omega .8
  4626.       octaves 8
  4627.       color_map {
  4628.         [0.00 color rgb <.5, .25, .15>]
  4629.         [0.33 color rgb <.1, .5, .4>]
  4630.         [0.86 color rgb <.6, .3, .1>]
  4631.         [1.00 color rgb <.5, .25, .15>]
  4632.       }
  4633.     }
  4634.     normal {
  4635.       bozo
  4636.       turbulence .5
  4637.       lambda 2
  4638.       normal_map {
  4639.         [0.4 dents .15 scale .01]
  4640.         [0.6 agate turbulence 1]
  4641.         [1.0 dents .15 scale .01]
  4642.       }
  4643.     }
  4644.   }
  4645. Looking at the resulting image we see that indeed our idea works!
  4646. The land areas are bumpy while the oceans are smooth. We add the
  4647. cloud layer back in and our planetoid is complete.
  4648.  
  4649. There is much more that we did not cover here due to space
  4650. constraints. On our own, we should take the time to explore slope
  4651. maps, average and bump maps.
  4652.  
  4653.  
  4654. 2.7.3     Finishes
  4655. The final part of a POV-Ray texture is the finish. It controls
  4656. the properties of the surface of an object. It can make it shiny
  4657. and reflective, or dull and flat. It can also specify what
  4658. happens to light that passes through transparent pigments, what
  4659. happens to light that is scattered by less-than-perfectly-smooth
  4660. surfaces and what happens to light that is reflected by surfaces
  4661. with thin-film interference properties. There are twelve
  4662. different properties available in POV-Ray to specify the finish
  4663. of a given object. These are controlled by the following
  4664. keywords: ambient, diffuse, brilliance, phong, specular,
  4665. metallic, reflection, crand and iridescence. Let's design a
  4666. couple of textures that make use of these parameters.
  4667.  
  4668.  
  4669. 2.7.3.1   Using Ambient
  4670. Since objects in POV-Ray are illuminated by light sources, the
  4671. portions of those objects that are in shadow would be completely
  4672. black were it not for the first two finish properties, ambient
  4673. and diffuse. Ambient is used to simulate the light that is
  4674. scattered around the scene that does not come directly from a
  4675. light source. Diffuse determines how much of the light that is
  4676. seen comes directly from a light source. These two keywords work
  4677. together to control the simulation of ambient light. Let's use
  4678. our gray sphere to demonstrate this. Let's also change our plane
  4679. back to its original green and white checkered pattern.
  4680.  
  4681.   plane {y,-1.5
  4682.     pigment {checker Green, White}
  4683.   }
  4684.   sphere { <0,0,0>, 1
  4685.     pigment {Gray75}
  4686.     finish {
  4687.       ambient .2
  4688.       diffuse .6
  4689.   }
  4690. In the above example, the default values for ambient and diffuse
  4691. are used. We render this to see what the effect is and then make
  4692. the following change to the finish.
  4693.  
  4694.   ambient 0
  4695.   diffuse 0
  4696. The sphere is black because we have specified that none of the
  4697. light coming from any light source will be reflected by the
  4698. sphere. Let's change diffuse back to the default of 0.6.
  4699.  
  4700. Now we see the gray surface color where the light from the light
  4701. source falls directly on the sphere but the shaded side is still
  4702. absolutely black. Now let's change diffuse to 0.3 and ambient to
  4703. 0.3.
  4704.  
  4705. The sphere now looks almost flat. This is because we have
  4706. specified a fairly high degree of ambient light and only a low
  4707. amount of the light coming from the light source is diffusely
  4708. reflected towards the camera. The default values of ambient and
  4709. diffuse are pretty good averages and a good starting point. In
  4710. most cases, an ambient value of 0.1 ... 0.2 is sufficient and a
  4711. diffuse value of 0.5 ... 0.7 will usually do the job. There are a
  4712. couple of exceptions. If we have a completely transparent surface
  4713. with high refractive and/or reflective values, low values of both
  4714. ambient and diffuse may be best. Here is an example:
  4715.  
  4716. sphere { <0,0,0>, 1
  4717.    pigment { White filter 1 }
  4718.    finish {
  4719.       ambient 0
  4720.       diffuse 0
  4721.       reflection .25
  4722.       specular 1
  4723.       roughness .001
  4724.    }
  4725.    interior{ior 1.33}
  4726. }
  4727. This is glass, obviously. Glass is a material that takes nearly
  4728. all of its appearance from its surroundings. Very little of the
  4729. surface is seen because it transmits or reflects practically all
  4730. of the light that shines on it. See glass.inc for some other
  4731. examples.
  4732.  
  4733. If we ever need an object to be completely illuminated
  4734. independently of the lighting situation in a given scene we can
  4735. do this artificially by specifying an ambient value of 1 and a
  4736. diffuse value of 0. This will eliminate all shading and simply
  4737. give the object its fullest and brightest color value at all
  4738. points. This is good for simulating objects that emit light like
  4739. light bulbs and for skies in scenes where the sky may not be
  4740. adequately lit by any other means.
  4741.  
  4742. Let's try this with our sphere now.
  4743.  
  4744.   sphere { <0,0,0>, 1
  4745.      pigment { White }
  4746.      finish {
  4747.         ambient 1
  4748.         diffuse 0
  4749.      }
  4750.   }
  4751. Rendering this we get a blinding white sphere with no visible
  4752. highlights or shaded parts. It would make a pretty good
  4753. streetlight.
  4754.  
  4755.  
  4756. 2.7.3.2   Using Surface Highlights
  4757. In the glass example above, we noticed that there were bright
  4758. little hotspots on the surface. This gave the sphere a hard,
  4759. shiny appearance. POV-Ray gives us two ways to specify surface
  4760. specular highlights. The first is called Phong highlighting.
  4761. Usually, Phong highlights are described using two keywords: phong
  4762. and phong_size. The float that follows phong determines the
  4763. brightness of the highlight while the float following phong_size
  4764. determines its size. Let's try this.
  4765.  
  4766.   sphere { <0,0,0>, 1
  4767.     pigment { Gray50 }
  4768.     finish {
  4769.       ambient .2
  4770.       diffuse .6
  4771.       phong .75
  4772.       phong_size 25
  4773.     }
  4774.   }
  4775. Rendering this we see a fairly broad, soft highlight that gives
  4776. the sphere a kind of plastic appearance. Now let's change
  4777. phong_size to 150. This makes a much smaller highlight which
  4778. gives the sphere the appearance of being much harder and shinier.
  4779.  
  4780. There is another kind of highlight that is calculated by a
  4781. different means called specular highlighting. It is specified
  4782. using the keyword specular and operates in conjunction with
  4783. another keyword called roughness. These two keywords work
  4784. together in much the same way as phong and phong_size to create
  4785. highlights that alter the apparent shininess of the surface.
  4786. Let's try using specular in our sphere.
  4787.  
  4788.   sphere { <0,0,0>, 1
  4789.      pigment { Gray50 }
  4790.      finish {
  4791.         ambient .2
  4792.         diffuse .6
  4793.         specular .75
  4794.         roughness .1
  4795.     }
  4796.   }
  4797. Looking at the result we see a broad, soft highlight similar to
  4798. what we had when we used phong_size of 25. Change roughness to
  4799. .001 and render again. Now we see a small, tight highlight
  4800. similar to what we had when we used phong_size of 150. Generally
  4801. speaking, specular is slightly more accurate and therefore
  4802. slightly more realistic than phong but you should try both
  4803. methods when designing a texture. There are even times when both
  4804. phong and specular may be used on a finish.
  4805.  
  4806.  
  4807. 2.7.3.3   Using Reflection and Metallic
  4808. There is another surface parameter that goes hand in hand with
  4809. highlights, reflection. Surfaces that are very shiny usually have
  4810. a degree of reflection to them. Let's take a look at an example.
  4811.  
  4812.   sphere { <0,0,0>, 1
  4813.      pigment { Gray50 }
  4814.      finish {
  4815.         ambient .2
  4816.         diffuse .6
  4817.         specular .75
  4818.         roughness .001
  4819.         reflection .5
  4820.      }
  4821.   }
  4822. We see that our sphere now reflects the green and white checkered
  4823. plane and the black background but the gray color of the sphere
  4824. seems out of place. This is another time when a lower diffuse
  4825. value is needed.  Generally, the higher reflection is the lower
  4826. diffuse should be. We lower the diffuse value to 0.3 and the
  4827. ambient value to 0.1 and render again. That is much better. Let's
  4828. make our sphere as shiny as a polished gold ball bearing.
  4829.  
  4830.   sphere { <0,0,0>, 1
  4831.      pigment { BrightGold }
  4832.      finish {
  4833.         ambient .1
  4834.         diffuse .1
  4835.         specular 1
  4836.         roughness .001
  4837.         reflection .75
  4838.      }
  4839.    }
  4840. That is very close but there is something wrong with the
  4841. highlight. To make the surface appear more like metal the keyword
  4842. metallic is used. We add it now to see the difference.
  4843.  
  4844.   sphere { <0,0,0>, 1
  4845.      pigment { BrightGold }
  4846.      finish {
  4847.         ambient .1
  4848.         diffuse .1
  4849.         specular 1
  4850.         roughness .001
  4851.         reflection .75
  4852.         metallic
  4853.      }
  4854.   }
  4855. We see that the highlight has taken on the color of the surface
  4856. rather than the light source. This gives the surface a more
  4857. metallic appearance.
  4858.  
  4859.  
  4860. 2.7.3.4   Using Iridescence
  4861. Iridescence is what we see on the surface of an oil slick when
  4862. the sun shines on it. The rainbow effect is created by something
  4863. called thin-film interference (read section "Iridescence" for
  4864. details). For now let's just try using it. Iridescence is
  4865. specified by the irid statement and three values: amount,
  4866. thickness and turbulence. The amount is the contribution to the
  4867. overall surface color. Usually 0.1 to 0.5 is sufficient here. The
  4868. thickness affects the "busyness" of the effect. Keep this between
  4869. 0.25 and 1 for best results. The turbulence is a little different
  4870. from pigment or normal turbulence. We cannot set octaves, lambda
  4871. or omega but we can specify an amount which will affect the
  4872. thickness in a slightly different way from the thickness value.
  4873. Values between 0.25 and 1 work best here too. Finally,
  4874. iridescence will respond to the surface normal since it depends
  4875. on the angle of incidence of the light rays striking the surface.
  4876. With all of this in mind, let's add some iridescence to our glass
  4877. sphere.
  4878.  
  4879. sphere { <0,0,0>, 1
  4880.      pigment { White filter 1 }
  4881.      finish {
  4882.         ambient .1
  4883.         diffuse .1
  4884.         reflection .2
  4885.         specular 1
  4886.         roughness .001
  4887.         irid {
  4888.           0.35
  4889.           thickness .5
  4890.           turbulence .5
  4891.         }
  4892.      }
  4893.      interior{
  4894.         ior 1.5
  4895.         fade_distance 5
  4896.         fade_power 1
  4897.         caustics 1
  4898.      }
  4899. }
  4900. We try to vary the values for amount, thickness and turbulence to
  4901. see what changes they make. We also try to add a normal block to
  4902. see what happens.
  4903.  
  4904.  
  4905. 2.7.4     Working With Pigment Maps
  4906. Let's look at the pigment map. We must not confuse this with a
  4907. color map, as color maps can only take individual colors as
  4908. entries in the map, while pigment maps can use entire other
  4909. pigment patterns. To get a feel for these, let's begin by setting
  4910. up a basic plane with a simple pigment map. Now, in the following
  4911. example, we are going to declare each of the pigments we are
  4912. going to use before we actually use them. This isn't strictly
  4913. necessary (we could put an entire pigment description in each
  4914. entry of the map) but it just makes the whole thing more
  4915. readable.
  4916.  
  4917.   // simple Black on White checkboard... it's a classic
  4918.   #declare Pigment1 = pigment {
  4919.     checker color Black color White
  4920.     scale .1
  4921.   }
  4922.   // kind of a "psychedelic rings" effect
  4923.   #declare Pigment2 = pigment {
  4924.     wood
  4925.     color_map {
  4926.       [ 0.0 Red ]
  4927.       [ 0.3 Yellow ]
  4928.       [ 0.6 Green ]
  4929.       [ 1.0 Blue ]
  4930.     }
  4931.   }
  4932.   plane { -z, 0
  4933.     pigment {
  4934.       gradient x
  4935.       pigment_map {
  4936.         [ 0.0 Pigment1 ]
  4937.         [ 0.5 Pigment2 ]
  4938.         [ 1.0 Pigment1 ]
  4939.       }
  4940.     }
  4941.   }
  4942. Okay, what we have done here is very simple, and probably quite
  4943. recognizable if we have been working with color maps all along
  4944. anyway. All we have done is substituted a pigment map where a
  4945. color map would normally go, and as the entries in our map, we
  4946. have referenced our declared pigments. When we render this
  4947. example, we see a pattern which fades back and forth between the
  4948. classic checkerboard, and those colorful rings. Because we fade
  4949. from Pigment1 to Pigment2 and then back again, we see a clear
  4950. blending of the two patterns at the transition points. We could
  4951. just as easily get a sudden transition by amending the map to
  4952. read.
  4953.  
  4954.   pigment_map {
  4955.     [ 0.0 Pigment1 ]
  4956.     [ 0.5 Pigment1 ]
  4957.     [ 0.5 Pigment2 ]
  4958.     [ 1.0 Pigment2 ]
  4959.   }
  4960. Blending individual pigment patterns is just the beginning.
  4961.  
  4962.  
  4963. 2.7.5     Working With Normal Maps
  4964.  For our next example, we replace the plane in the scene with
  4965. this one.
  4966.  
  4967.   plane { -z, 0
  4968.     pigment { White }
  4969.     normal {
  4970.       gradient x
  4971.       normal_map {
  4972.         [ 0.0 bumps 1 scale .1]
  4973.         [ 1.0 ripples 1 scale .1]
  4974.       }
  4975.     }
  4976.   }
  4977. First of all, we have chosen a solid white color to show off all
  4978. bumping to best effect. Secondly, we notice that our map blends
  4979. smoothly from all bumps at 0.0 to all ripples at 1.0, but because
  4980. this is a default gradient, it falls off abruptly back to bumps
  4981. at the beginning of the next cycle. We Render this and see just
  4982. enough sharp transitions to clearly see where one normal gives
  4983. over to another, yet also an example of how two normal patterns
  4984. look while they are smoothly blending into one another.
  4985.  
  4986. The syntax is the same as we would expect. We just changed the
  4987. type of map, moved it into the normal block and supplied
  4988. appropriate bump types. It is important to remember that as of
  4989. POV-Ray 3, all patterns that work with pigments work as normals
  4990. as well (and vice versa, of course) so we could just as easily
  4991. have blended from wood to granite, or any other pattern we like.
  4992. We experiment a bit and get a feel for what the different
  4993. patterns look like.
  4994.  
  4995. After seeing how interesting the various normals look blended, we
  4996. might like to see them completely blended all the way through
  4997. rather than this business of fading from one to the next. Well,
  4998. that is possible too, but we would be getting ahead of ourselves.
  4999. That is called the average function, and we will return to it a
  5000. little bit further down the page.
  5001.  
  5002.  
  5003. 2.7.6     Working With Texture Maps
  5004. We know how to blend colors, pigment patterns, and normals, and
  5005. we are probably thinking what about finishes? What about whole
  5006. textures? Both of these can be kind of covered under one topic.
  5007. While there is no finish map per se, there are texture maps, and
  5008. we can easily adapt these to serve as finish maps, simply by
  5009. putting the same pigment and/or normal in each of the texture
  5010. entries of the map. Here is an example. We eliminate the declared
  5011. pigments we used before and the previous plane, and add the
  5012. following.
  5013.  
  5014.   #declare Texture1 = texture {
  5015.     pigment { Grey }
  5016.     finish { reflection 1 }
  5017.   }
  5018.   #declare Texture2 = texture {
  5019.     pigment { Grey }
  5020.     finish { reflection 0 }
  5021.   }
  5022.   cylinder { <-2, 5, -2>, <-2, -5, -2>, 1
  5023.     pigment { Blue }
  5024.   }
  5025.   plane { -z, 0
  5026.     rotate y * 30
  5027.     texture {
  5028.       gradient y
  5029.       texture_map {
  5030.         [ 0.0 Texture1 ]
  5031.         [ 0.4 Texture1 ]
  5032.         [ 0.6 Texture2 ]
  5033.         [ 1.0 Texture2 ]
  5034.       }
  5035.       scale 2
  5036.     }
  5037.   }
  5038. Now, what have we done here? The background plane alternates
  5039. vertically between two textures, identical except for their
  5040. finishes. When we render this, the cylinder has a reflection part
  5041. of the way down the plane, and then stops reflecting, then begins
  5042. and then stops again, in a gradient pattern down the surface of
  5043. the plane. With a little adaptation, this could be used with any
  5044. pattern, and in any number of creative ways, whether we just
  5045. wanted to give various parts of an object different finishes, as
  5046. we are doing here, or whole different textures altogether.
  5047.  
  5048. One might ask: if there is a texture map, why do we need pigment
  5049. and normal maps? Fair question. The answer: speed of calculation.
  5050. If we use a texture map, for every in-between point, POV-Ray must
  5051. make multiple calculations for each texture element, and then run
  5052. a weighted average to produce the correct value for that point.
  5053. Using just a pigment map (or just a normal map) decreases the
  5054. overall number of calculations, and our texture renders a bit
  5055. faster in the bargain. As a rule of thumb: we use pigment or
  5056. normal maps where we can and only fall back on texture maps if we
  5057. need the extra flexibility.
  5058.  
  5059.  
  5060. 2.7.7     Working With List Textures
  5061.  If we have followed the corresponding tutorials on simple
  5062. pigments, we know that there are three patterns called color list
  5063. patterns, because rather than using a color map, these simple but
  5064. useful patterns take a list of colors immediately following the
  5065. pattern keyword. We're talking about checker, hexagon, and, new
  5066. to POV-Ray 3, the brick pattern.
  5067.  
  5068. Naturally they also work with whole pigments, normals, and entire
  5069. textures, just as the other patterns do above. The only
  5070. difference is that we list entries in the pattern (as we would do
  5071. with individual colors) rather than using a map of entries. Here
  5072. is an example. We strike the plane and any declared pigments we
  5073. had left over in our last example, and add the following to our
  5074. basic file.
  5075.  
  5076.   #declare Pigment1 = pigment {
  5077.     hexagon
  5078.     color Yellow color Green color Grey
  5079.     scale .1
  5080.   }
  5081.   #declare Pigment2 = pigment {
  5082.     checker
  5083.     color Red color Blue
  5084.     scale .1
  5085.   }
  5086.   #declare Pigment3 = pigment {
  5087.     brick
  5088.     color White color Black
  5089.     rotate -90*x
  5090.     scale .1
  5091.   }
  5092.   box { -5, 5
  5093.     pigment {
  5094.       hexagon
  5095.       pigment {Pigment1}
  5096.       pigment {Pigment2}
  5097.       pigment {Pigment3}
  5098.       rotate 90*x
  5099.     }
  5100.   }
  5101. We begin by declaring an example of each of the color list
  5102. patterns as individual pigments. Then we use the hexagon pattern
  5103. as a pigment list pattern, simply feeding it a list of pigments
  5104. rather than colors as we did above. There are two rotate
  5105. statements throughout this example, because bricks are aligned
  5106. along the z-direction, while hexagons align along the y-
  5107. direction, and we wanted everything to face toward the camera we
  5108. originally declared out in the -z-direction so we can really see
  5109. the patterns within patterns effect here.
  5110.  
  5111. Of course color list patterns used to be only for pigments, but
  5112. as of POV-Ray 3, everything that worked for pigments can now also
  5113. be adapted for normals or entire textures. A couple of quick
  5114. examples might look like
  5115.  
  5116.   normal {
  5117.     brick
  5118.     normal { granite .1 }
  5119.     normal { bumps 1 scale .1 }
  5120.   }
  5121. or...
  5122.  
  5123.   texture {
  5124.     checker
  5125.     texture { Gold_Metal }
  5126.     texture { Silver_Metal }
  5127.   }
  5128.  
  5129. 2.7.8     What About Tiles?
  5130. In earlier versions of POV-Ray, there was a texture pattern
  5131. called tiles. By simply using a checker texture pattern (as we
  5132. just saw above), we can achieve the same thing as tiles used to
  5133. do, so it is now obsolete. It is still supported by POV-Ray 3 for
  5134. backwards compatibility with old scene files, but now is a good
  5135. time to get in the habit of using a checker pattern instead.
  5136.  
  5137.  
  5138. 2.7.9     Average Function
  5139. Now things get interesting. Above, we began to see how pigments
  5140. and normals can fade from one to the other when we used them in
  5141. maps. But how about if we want a smooth blend of patterns all the
  5142. way through? That is where a new feature called average can come
  5143. in very handy. Average works with pigment, normal, and texture
  5144. maps, although the syntax is a little bit different, and when we
  5145. are not expecting it, the change can be confusing. Here is a
  5146. simple example. We use our standard includes, camera and light
  5147. source from above, and enter the following object.
  5148.  
  5149.   plane { -z, 0
  5150.     pigment { White }
  5151.     normal {
  5152.       average
  5153.       normal_map {
  5154.         [ gradient x ]
  5155.         [ gradient y ]
  5156.       }
  5157.     }
  5158.   }
  5159. What we have done here is pretty self explanatory as soon as we
  5160. render it. We have combined a vertical with a horizontal gradient
  5161. bump pattern, creating crisscrossing gradients. Actually, the
  5162. crisscrossing effect is a smooth blend of gradient x with
  5163. gradient y all the way across our plane. Now, what about that
  5164. syntax difference?
  5165.  
  5166. We see how our normal map has changed from earlier examples. The
  5167. floating point value to the left-hand side of each map entry has
  5168. been removed.  That value usually helps in procedurally mapping
  5169. each entry to the pattern we have selected, but average is a
  5170. smooth blend all the way through, not a pattern, so it cannot use
  5171. those values. In fact, including them may sometimes lead to
  5172. unexpected results, such as entries being lost or misrepresented
  5173. in some way. To ensure that we'll get the pattern blend we
  5174. anticipate, we leave off the floating point value.
  5175.  
  5176.  
  5177. 2.7.10    Working With Layered Textures
  5178. With the multitudinous colors, patterns, and options for creating
  5179. complex textures in POV-Ray, we can easily become deeply
  5180. engrossed in mixing and tweaking just the right textures to apply
  5181. to our latest creations. But as we go, sooner or later there is
  5182. going to come that special texture. That texture that is sort of
  5183. like wood, only varnished, and with a kind of spotty yellow
  5184. streaking, and some vertical gray flecks, that looks like someone
  5185. started painting over it all, and then stopped, leaving part of
  5186. the wood visible through the paint.
  5187.  
  5188. Only... now what? How do we get all that into one texture? No
  5189. pattern can do that many things. Before we panic and say image
  5190. map there is at least one more option: layered textures.
  5191.  
  5192. With layered textures, we only need to specify a series of
  5193. textures, one after the other, all associated with the same
  5194. object. Each texture we list will be applied one on top of the
  5195. other, from bottom to top in the order they appear.
  5196.  
  5197. It is very important to note that we must have some degree of
  5198. transparency (filter or transmit) in the pigments of our upper
  5199. textures, or the ones below will get lost underneath. We won't
  5200. receive a warning or an error - technically it is legal to do
  5201. this: it just doesn't make sense. It is like spending hours
  5202. sketching an elaborate image on a bare wall, then slapping a
  5203. solid white coat of latex paint over it.
  5204.  
  5205. Let's design a very simple object with a layered texture, and
  5206. look at how it works. We create a file called LAYTEX.POV and add
  5207. the following lines.
  5208.  
  5209.   #include "colors.inc"
  5210.   #include "textures.inc"
  5211.   camera {
  5212.     location <0, 5, -30>
  5213.     look_at <0, 0, 0>
  5214.   }
  5215.   light_source { <-20, 30, -50> color White }
  5216.   plane { y, 0 pigment { checker color Green color Yellow  } }
  5217.   background { rgb <.7, .7, 1> }
  5218.   box { <-10, 0, -10>, <10, 10, 10>
  5219.     texture {
  5220.       Silver_Metal // a metal object ...
  5221.       normal {     // ... which has suffered a beating
  5222.         dents 2
  5223.         scale 1.5
  5224.       }
  5225.     } // (end of base texture)
  5226.     texture { // ... has some flecks of rust ...
  5227.       pigment {
  5228.         granite
  5229.         color_map {
  5230.           [0.0 rgb <.2, 0, 0> ]
  5231.           [0.2 color Brown ]
  5232.           [0.2 rgbt <1, 1, 1, 1> ]
  5233.           [1.0 rgbt <1, 1, 1, 1> ]
  5234.         }
  5235.         frequency 16
  5236.       }
  5237.     } // (end rust fleck texture)
  5238.     texture { // ... and some sooty black marks
  5239.       pigment {
  5240.         bozo
  5241.         color_map {
  5242.           [0.0 color Black ]
  5243.           [0.2 color rgbt <0, 0, 0, .5> ]
  5244.           [0.4 color rgbt <.5, .5, .5, .5> ]
  5245.           [0.5 color rgbt <1, 1, 1, 1> ]
  5246.           [1.0 color rgbt <1, 1, 1, 1> ]
  5247.         }
  5248.         scale 3
  5249.       }
  5250.     } // (end of sooty mark texture)
  5251.   } // (end of box declaration)
  5252. Whew. This gets complicated, so to make it easier to read, we
  5253. have included comments showing what we are doing and where
  5254. various parts of the declaration end (so we don't get lost in all
  5255. those closing brackets!). To begin, we created a simple box over
  5256. the classic checkerboard floor, and give the background sky a
  5257. pale blue color. Now for the fun part...
  5258.  
  5259. To begin with we made the box use the Silver_Metal texture as
  5260. declared in textures.inc (for bonus points, look up textures.inc
  5261. and see how this standard texture was originally created
  5262. sometime). To give it the start of its abused state, we added the
  5263. dents normal pattern, which creates the illusion of some denting
  5264. in the surface as if our mysterious metal box had been knocked
  5265. around quite a bit.
  5266.  
  5267. The flecks of rust are nothing but a fine grain granite pattern
  5268. fading from dark red to brown which then abruptly drops to fully
  5269. transparent for the majority of the color map. True, we could
  5270. probably come up with a more realistic pattern of rust using
  5271. pigment maps to cluster rusty spots, but pigment maps are a
  5272. subject for another tutorial section, so let's skip that just
  5273. now.
  5274.  
  5275. Lastly, we have added a third texture to the pot. The randomly
  5276. shifting bozo texture gradually fades from blackened centers to
  5277. semi-transparent medium gray, and then ultimately to fully
  5278. transparent for the latter half of its color map. This gives us a
  5279. look of sooty burn marks further marring the surface of the metal
  5280. box. The final result leaves our mysterious metal box looking
  5281. truly abused, using multiple texture patterns, one on top of the
  5282. other, to produce an effect that no single pattern could
  5283. generate!
  5284.  
  5285.  
  5286. 2.7.10.1  Declaring Layered Textures
  5287. In the event we want to reuse a layered texture on several
  5288. objects in our scene, it is perfectly legal to declare a layered
  5289. texture. We won't repeat the whole texture from above, but the
  5290. general format would be something like this:
  5291.  
  5292.   #declare Abused_Metal =
  5293.     texture { /* insert your base texture here... */ }
  5294.     texture { /* and your rust flecks here... */ }
  5295.     texture { /* and of course, your sooty burn marks here */ }
  5296. POV-Ray has no problem spotting where the declaration ends,
  5297. because the textures follow one after the other with no objects
  5298. or directives in between. The layered texture to be declared will
  5299. be assumed to continue until it finds something other than
  5300. another texture, so any number of layers can be added in to a
  5301. declaration in this fashion.
  5302.  
  5303. One final word about layered textures: whatever layered texture
  5304. we create, whether declared or not, we must not leave off the
  5305. texture wrapper. In conventional single textures a common
  5306. shorthand is to have just a pigment, or just a pigment and
  5307. finish, or just a normal, or whatever, and leave them outside of
  5308. a texture statement. This shorthand does not extend to layered
  5309. textures. As far as POV-Ray is concerned we can layer entire
  5310. textures, but not individual pieces of textures. For example
  5311.  
  5312.   #declare Bad_Texture =
  5313.     texture { /* insert your base texture here... */ }
  5314.     pigment { Red filter .5 }
  5315.     normal { bumps 1 }
  5316. will not work. The pigment and the normal are just floating there
  5317. without being part of any particular texture. Inside an object,
  5318. with just a single texture, we can do this sort of thing, but
  5319. with layered textures, we would just generate an error whether
  5320. inside the object or in a declaration.
  5321.  
  5322.  
  5323. 2.7.10.2  Another Layered Textures Example
  5324. To further explain how layered textures work another example is
  5325. described in detail. A tablecloth is created to be used in a
  5326. picnic scene. Since a simple red and white checkered cloth looks
  5327. entirely too new, too flat, and too much like a tiled floor,
  5328. layered textures are used to stain the cloth.
  5329.  
  5330. We're going to create a scene containing four boxes. The first
  5331. box has that plain red and white texture we started with in our
  5332. picnic scene, the second adds a layer meant to realistically fade
  5333. the cloth, the third adds some wine stains, and the final box
  5334. adds a few wrinkles (not another layer, but we must note when and
  5335. where adding changes to the surface normal have an effect in
  5336. layered textures).
  5337.  
  5338. We start by placing a camera, some lights, and the first box. At
  5339. this stage, the texture is plain tiling, not layered. See file
  5340. layered1.pov.
  5341.  
  5342.   #include "colors.inc"
  5343.   camera {
  5344.     location <0, 0, -6>
  5345.     look_at <0, 0, 0>
  5346.   }
  5347.   light_source { <-20, 30, -100> color White }
  5348.   light_source { <10, 30, -10> color White }
  5349.   light_source { <0, 30, 10> color White }
  5350.   #declare PLAIN_TEXTURE =
  5351.     // red/white check
  5352.     texture {
  5353.       pigment {
  5354.         checker
  5355.         color rgb<1.000, 0.000, 0.000>
  5356.         color rgb<1.000, 1.000, 1.000>
  5357.         scale <0.2500, 0.2500, 0.2500>
  5358.       }
  5359.     }
  5360.   // plain red/white check box
  5361.   box { <-1, -1, -1>, <1, 1, 1>
  5362.     texture {
  5363.       PLAIN_TEXTURE
  5364.     }
  5365.     translate  <-1.5, 1.2, 0>
  5366.   }
  5367. We render this scene. It is not particularly interesting, isn't
  5368. it? That is why we will use some layered textures to make it more
  5369. interesting.
  5370.  
  5371. First, we add a layer of two different, partially transparent
  5372. grays. We tile them as we had tiled the red and white colors, but
  5373. we add some turbulence to make the fading more realistic. We add
  5374. following box to the previous scene and re-render (see file
  5375. layered2.pov).
  5376.  
  5377.   #declare FADED_TEXTURE =
  5378.     // red/white check texture
  5379.     texture {
  5380.       pigment {
  5381.         checker
  5382.         color rgb<0.920, 0.000, 0.000>
  5383.         color rgb<1.000, 1.000, 1.000>
  5384.         scale <0.2500, 0.2500, 0.2500>
  5385.       }
  5386.     }
  5387.     // greys to fade red/white
  5388.     texture {
  5389.       pigment {
  5390.         checker
  5391.         color rgbf<0.632, 0.612, 0.688, 0.698>
  5392.         color rgbf<0.420, 0.459, 0.520, 0.953>
  5393.         turbulence 0.500
  5394.         scale <0.2500, 0.2500, 0.2500>
  5395.       }
  5396.     }
  5397.   // faded red/white check box
  5398.   box { <-1, -1, -1>, <1, 1, 1>
  5399.     texture {
  5400.       FADED_TEXTURE
  5401.     }
  5402.     translate  <1.5, 1.2, 0>
  5403.   }
  5404. Even though it is a subtle difference, the red and white checks
  5405. no longer look quite so new.
  5406.  
  5407. Since there is a bottle of wine in the picnic scene, we thought
  5408. it might be a nice touch to add a stain or two. While this effect
  5409. can almost be achieved by placing a flattened blob on the cloth,
  5410. what we really end up with is a spill effect, not a stain. Thus
  5411. it is time to add another layer.
  5412.  
  5413. Again, we add another box to the scene we already have scripted
  5414. and re-render (see file layered3.pov).
  5415.  
  5416.   #declare STAINED_TEXTURE =
  5417.     // red/white check
  5418.     texture {
  5419.       pigment {
  5420.         checker
  5421.         color rgb<0.920, 0.000, 0.000>
  5422.         color rgb<1.000, 1.000, 1.000>
  5423.         scale <0.2500, 0.2500, 0.2500>
  5424.       }
  5425.     }
  5426.     // greys to fade check
  5427.     texture {
  5428.       pigment {
  5429.         checker
  5430.         color rgbf<0.634, 0.612, 0.688, 0.698>
  5431.         color rgbf<0.421, 0.463, 0.518, 0.953>
  5432.         turbulence 0.500
  5433.         scale <0.2500, 0.2500, 0.2500>
  5434.       }
  5435.     }
  5436.     // wine stain
  5437.     texture {
  5438.       pigment {
  5439.         spotted
  5440.         color_map {
  5441.           [ 0.000  color rgb<0.483, 0.165, 0.165> ]
  5442.           [ 0.329  color rgbf<1.000, 1.000, 1.000, 1.000> ]
  5443.           [ 0.734  color rgbf<1.000, 1.000, 1.000, 1.000> ]
  5444.           [ 1.000  color rgb<0.483, 0.165, 0.165> ]
  5445.         }
  5446.         turbulence 0.500
  5447.         frequency 1.500
  5448.       }
  5449.     }
  5450.   // stained box
  5451.   box { <-1, -1, -1>, <1, 1, 1>
  5452.     texture {
  5453.       STAINED_TEXTURE
  5454.     }
  5455.     translate  <-1.5, -1.2, 0>
  5456.   }
  5457. Now there's a tablecloth texture with personality.
  5458.  
  5459. Another touch we want to add to the cloth are some wrinkles as if
  5460. the cloth had been rumpled. This is not another texture layer,
  5461. but when working with layered textures, we must keep in mind that
  5462. changes to the surface normal must be included in the uppermost
  5463. layer of the texture. Changes to lower layers have no effect on
  5464. the final product (no matter how transparent the upper layers
  5465. are).
  5466.  
  5467. We add this final box to the script and re-render (see file
  5468. layered4.pov)
  5469.  
  5470.   #declare WRINKLED_TEXTURE =
  5471.     // red and white check
  5472.     texture {
  5473.       pigment {
  5474.         checker
  5475.         color rgb<0.920, 0.000, 0.000>
  5476.         color rgb<1.000, 1.000, 1.000>
  5477.         scale <0.2500, 0.2500, 0.2500>
  5478.       }
  5479.     }
  5480.     // greys to "fade" checks
  5481.     texture {
  5482.       pigment {
  5483.         checker
  5484.         color rgbf<0.632, 0.612, 0.688, 0.698>
  5485.         color rgbf<0.420, 0.459, 0.520, 0.953>
  5486.         turbulence 0.500
  5487.         scale <0.2500, 0.2500, 0.2500>
  5488.       }
  5489.     }
  5490.     // the wine stains
  5491.     texture {
  5492.       pigment {
  5493.         spotted
  5494.         color_map {
  5495.           [ 0.000  color rgb<0.483, 0.165, 0.165> ]
  5496.           [ 0.329  color rgbf<1.000, 1.000, 1.000, 1.000> ]
  5497.           [ 0.734  color rgbf<1.000, 1.000, 1.000, 1.000> ]
  5498.           [ 1.000  color rgb<0.483, 0.165, 0.165> ]
  5499.         }
  5500.         turbulence 0.500
  5501.         frequency 1.500
  5502.       }
  5503.       normal {
  5504.         wrinkles 5.0000
  5505.       }
  5506.     }
  5507.   // wrinkled box
  5508.   box { <-1, -1, -1>, <1, 1, 1>
  5509.     texture {
  5510.       WRINKLED_TEXTURE
  5511.     }
  5512.     translate  <1.5, -1.2, 0>
  5513.   }
  5514. Well, this may not be the tablecloth we want at any picnic we're
  5515. attending, but if we compare the final box to the first, we see
  5516. just how much depth, dimension, and personality is possible just
  5517. by the use of creative texturing.
  5518.  
  5519. One final note: the comments concerning the surface normal do not
  5520. hold true for finishes. If a lower layer contains a specular
  5521. finish and an upper layer does not, any place where the upper
  5522. layer is transparent, the specular will show through.
  5523.  
  5524.  
  5525. 2.7.11    When All Else Fails: Material Maps
  5526. We have some pretty powerful texturing tools at our disposal, but
  5527. what if we want a more free form arrangement of complex textures?
  5528. Well, just as image maps do for pigments, and bump maps do for
  5529. normals, whole textures can be mapped using a material map,
  5530. should the need arise.
  5531.  
  5532. Just as with image maps and bump maps, we need a source image in
  5533. bitmapped format which will be called by POV-Ray to serve as the
  5534. map of where the individual textures will go, but this time, we
  5535. need to specify what texture will be associated with which
  5536. palette index. To make such an image, we can use a paint program
  5537. which allows us to select colors by their palette index number
  5538. (the actual color is irrelevant, since it is only a map to tell
  5539. POV-Ray what texture will go at that location). Now, if we have
  5540. the complete package that comes with POV-Ray, we have in our
  5541. include files an image called povmap.gif which is a bitmapped
  5542. image that uses only the first four palette indices to create a
  5543. bordered square with the words "Persistence of Vision" in it.
  5544. This will do just fine as a sample map for the following example.
  5545. Using our same include files, the camera and light source, we
  5546. enter the following object.
  5547.  
  5548.   plane { -z, 0
  5549.     texture {
  5550.       material_map {
  5551.         gif "povmap.gif"
  5552.         interpolate 2
  5553.         once
  5554.         texture { PinkAlabaster }          // the inner border
  5555.         texture { pigment { DMFDarkOak } } // outer border
  5556.         texture { Gold_Metal }             // lettering
  5557.         texture { Chrome_Metal }           // the window panel
  5558.       }
  5559.       translate <-0.5, -0.5, 0>
  5560.       scale 5
  5561.     }
  5562.   }
  5563. The position of the light source and the lack of foreground
  5564. objects to be reflected do not show these textures off to their
  5565. best advantage. But at least we can see how the process works.
  5566. The textures have simply been placed according to the location of
  5567. pixels of a particular palette index. By using the once keyword
  5568. (to keep it from tiling), and translating and scaling our map to
  5569. match the camera we have been using, we get to see the whole
  5570. thing laid out for us.
  5571.  
  5572. Of course, that is just with palette mapped image formats, such
  5573. as GIF and certain flavors of PNG. Material maps can also use non-
  5574. paletted formats, such as the TGA files that POV-Ray itself
  5575. outputs. That leads to an interesting consequence: We can use POV-
  5576. Ray to produce source maps for POV-Ray! Before we wrap up with
  5577. some of the limitations of special textures, let's do one more
  5578. thing with material maps, to show how POV-Ray can make its own
  5579. source maps.
  5580.  
  5581. To begin with, if using an non-paletted image, POV-Ray looks at
  5582. the 8 bit red component of the pixel's color (which will be a
  5583. value from 0 to 255) to determine which texture from the list to
  5584. use. So to create a source map, we need to control very precisely
  5585. what the red value of a given pixel will be. We can do this by
  5586.  
  5587.   1.)  Using an rgb statement to choose our color such as rgb
  5588.   <N/255,0,0>, where "N" is the red value we want to assign that
  5589.   pigment, and then...
  5590.   2.)  Use no light sources and apply a finish of finish{ambient
  5591.   1} to all objects, to ensure that highlighting and shadowing
  5592.   will not interfere.
  5593. Confused? Alright, here is an example, which will generate a map
  5594. very much like povmap.gif which we used earlier, except in TGA
  5595. file format. We notice that we have given the pigments blue and
  5596. green components too. POV-Ray will ignore that in our final map,
  5597. so this is really for us humans, whose unaided eyes cannot tell
  5598. the difference between red variances of 0 to 4/255ths. Without
  5599. those blue and green variances, our map would look to our eyes
  5600. like a solid black screen. That may be a great way to send secret
  5601. messages using POV-Ray (plug it into a material map to decode)
  5602. but it is no use if we want to see what our source map looks like
  5603. to make sure we have what we expected to.
  5604.  
  5605. We render the following code, and name the resulting file
  5606. povmap.tga.
  5607.  
  5608.   camera {
  5609.     orthographic
  5610.     up <0, 5, 0>
  5611.     right <5, 0, 0>
  5612.     location <0, 0, -25>
  5613.     look_at <0, 0, 0>
  5614.   }
  5615.   plane { -z, 0
  5616.     pigment { rgb <1/255, 0, 0.5> }
  5617.     finish { ambient 1 }
  5618.   }
  5619.   box { <-2.3, -1.8, -0.2>, <2.3, 1.8, -0.2>
  5620.     pigment { rgb <0/255, 0, 1> }
  5621.     finish { ambient 1 }
  5622.   }
  5623.   box { <-1.95, -1.3, -0.4>, <1.95, 1.3, -0.3>
  5624.     pigment { rgb <2/255, 0.5, 0.5> }
  5625.     finish { ambient 1 }
  5626.   }
  5627.   text { ttf "crystal.ttf", "The vision", 0.1, 0
  5628.     scale <0.7, 1, 1>
  5629.     translate <-1.8, 0.25, -0.5>
  5630.     pigment { rgb <3/255, 1, 1> }
  5631.     finish { ambient 1 }
  5632.   }
  5633.   text { ttf "crystal.ttf", "Persists!", 0.1, 0
  5634.     scale <0.7, 1, 1>
  5635.     translate <-1.5, -1, -0.5>
  5636.     pigment { rgb <3/255, 1, 1> }
  5637.     finish { ambient 1 }
  5638.   }
  5639. All we have to do is modify our last material map example by
  5640. changing the material map from GIF to TGA and modifying the
  5641. filename. When we render using the new map, the result is
  5642. extremely similar to the palette mapped GIF we used before,
  5643. except that we didn't have to use an external paint program to
  5644. generate our source: POV-Ray did it all!
  5645.  
  5646.  
  5647. 2.7.12    Limitations Of Special Textures
  5648. There are a couple limitations to all of the special textures we
  5649. have seen (from textures, pigment and normal maps through
  5650. material maps). First, if we have used the default directive to
  5651. set the default texture for all items in our scene, it will not
  5652. accept any of the special textures discussed here.  This is
  5653. really quite minor, since we can always declare such a texture
  5654. and apply it individually to all objects. It doesn't actually
  5655. prevent us from doing anything we couldn't otherwise do.
  5656.  
  5657. The other is more limiting, but as we will shortly see, can be
  5658. worked around quite easily. If we have worked with layered
  5659. textures, we have already seen how we can pile multiple texture
  5660. patterns on top of one another (as long as one texture has
  5661. transparency in it). This very useful technique has a problem
  5662. incorporating the special textures we have just seen as a layer.
  5663. But there is an answer!
  5664.  
  5665. For example, say we have a layered texture called Speckled_Metal,
  5666. which produces a silver metallic surface, and then puts tiny
  5667. specks of rust all over it. Then we decide, for a really rusty
  5668. look, we want to create patches of concentrated rust, randomly
  5669. over the surface. The obvious approach is to create a special
  5670. texture pattern, with transparency to use as the top layer. But
  5671. of course, as we have seen, we wouldn't be able to use that
  5672. texture pattern as a layer. We would just generate an error
  5673. message. The solution is to turn the problem inside out, and make
  5674. our layered texture part of the texture pattern instead, like
  5675. this
  5676.  
  5677.   // This part declares a pigment for use
  5678.   // in the rust patch texture pattern
  5679.   #declare Rusty = pigment {
  5680.     granite
  5681.     color_map {
  5682.       [ 0 rgb <0.2, 0, 0> ]
  5683.       [ 1 Brown ]
  5684.     }
  5685.     frequency 20
  5686.   }
  5687.   // And this part applies it
  5688.   // Notice that our original layered texture
  5689.   // "Speckled_Metal" is now part of the map
  5690.   #declare Rust_Patches = texture {
  5691.     bozo
  5692.     texture_map {
  5693.       [ 0.0  pigment {Rusty} ]
  5694.       [ 0.75 Speckled_Metal ]
  5695.       [ 1.0  Speckled_Metal ]
  5696.     }
  5697.   }
  5698. And the ultimate effect is the same as if we had layered the rust
  5699. patches on to the speckled metal anyway.
  5700.  
  5701. With the full array of patterns, pigments, normals, finishes,
  5702. layered and special textures, there is now practically nothing we
  5703. cannot create in the way of amazing textures. An almost infinite
  5704. number of new possibilities are just waiting to be created!
  5705.  
  5706.  
  5707. 2.8  Using the Camera
  5708.  
  5709. 2.8.1     Using Focal Blur
  5710. Let's construct a simple scene to illustrate the use of focal
  5711. blur. For this example we will use a pink sphere, a green box and
  5712. a blue cylinder with the sphere placed in the foreground, the box
  5713. in the center and the cylinder in the background. A checkered
  5714. floor for perspective and a couple of light sources will complete
  5715. the scene. We create a new file called focaldem.pov and enter the
  5716. following text
  5717.  
  5718.   #include "colors.inc"
  5719.   #include "shapes.inc"
  5720.   #include "textures.inc"
  5721.   sphere { <1, 0, -6>, 0.5
  5722.     finish {
  5723.       ambient 0.1
  5724.       diffuse 0.6
  5725.     }
  5726.     pigment { NeonPink }
  5727.   }
  5728.   box { <-1, -1, -1>, < 1,  1,  1>
  5729.     rotate <0, -20, 0>
  5730.     finish {
  5731.       ambient 0.1
  5732.       diffuse 0.6
  5733.     }
  5734.     pigment { Green }
  5735.   }
  5736.   cylinder { <-6, 6, 30>, <-6, -1, 30>, 3
  5737.     finish {
  5738.       ambient 0.1
  5739.       diffuse 0.6
  5740.     }
  5741.     pigment {NeonBlue}
  5742.   }
  5743.   plane { y, -1.0
  5744.     pigment {
  5745.       checker color Gray65 color Gray30
  5746.     }
  5747.   }
  5748.   light_source { <5, 30, -30> color White }
  5749.   light_source { <-5, 30, -30> color White }
  5750. Now we can proceed to place our focal blur camera to an
  5751. appropriate viewing position. Straight back from our three
  5752. objects will yield a nice view. Adjusting the focal point will
  5753. move the point of focus anywhere in the scene. We just add the
  5754. following lines to the file:
  5755.  
  5756.   camera {
  5757.     location <0.0, 1.0, -10.0>
  5758.     look_at  <0.0, 1.0,  0.0>
  5759.   //  focal_point <-6, 1, 30>    // blue cylinder in focus
  5760.   //  focal_point < 0, 1,  0>    // green box in focus
  5761.     focal_point < 1, 1, -6>    // pink sphere in focus
  5762.     aperture 0.4     // a nice compromise
  5763.   //  aperture 0.05    // almost everything is in focus
  5764.   //  aperture 1.5     // much blurring
  5765.   //  blur_samples 4       // fewer samples, faster to render
  5766.     blur_samples 20      // more samples, higher quality image
  5767.   }
  5768. The focal point is simply the point at which the focus of the
  5769. camera is at its sharpest. We position this point in our scene
  5770. and assign a value to the aperture to adjust how close or how far
  5771. away we want the focal blur to occur from the focused area.
  5772.  
  5773. The aperture setting can be considered an area of focus. Opening
  5774. up the aperture has the effect of making the area of focus
  5775. smaller while giving the aperture a smaller value makes the area
  5776. of focus larger. This is how we control where focal blur begins
  5777. to occur around the focal point.
  5778.  
  5779. The blur samples setting determines how many rays are used to
  5780. sample each pixel. Basically, the more rays that are used the
  5781. higher the quality of the resultant image, but consequently the
  5782. longer it takes to render. Each scene is different so we have to
  5783. experiment.  This tutorial has examples of 4 and 20 samples but
  5784. we can use more for high resolution images. We should not use
  5785. more samples than is necessary to achieve the desired quality -
  5786. more samples take more time to render. The confidence and
  5787. variance settings are covered in section "Focal Blur".
  5788.  
  5789. We experiment with the focal point, aperture, and blur sample
  5790. settings.  The scene has lines with other values that we can try
  5791. by commenting out the default line with double slash marks and un-
  5792. commenting the line we wish to try out. We make only one change
  5793. at a time to see the effect on the scene.
  5794.  
  5795. Two final points when tracing a scene using a focal blur camera.
  5796. We needn't specify anti-aliasing because the focal blur code uses
  5797. its one sampling method that automatically takes care of anti-
  5798. aliasing. Focal blur can only be used with the perspective
  5799. camera.
  5800.  
  5801.  
  5802. 2.9  Using Atmospheric Effects
  5803. POV-Ray offers a variety of atmospheric effects, i. e. features
  5804. that affect the background of the scene or the air by which
  5805. everything is surrounded.
  5806.  
  5807. It is easy to assign a simple color or a complex color pattern to
  5808. a virtual sky sphere. You can create anything from a cloud free,
  5809. blue summer sky to a stormy, heavy clouded sky. Even starfields
  5810. can easily be created.
  5811.  
  5812. You can use different kinds of fog to create foggy scenes.
  5813. Multiple fog layers of different colors can add an eerie touch to
  5814. your scene.
  5815.  
  5816. A much more realistic effect can be created by using an
  5817. atmosphere, a constant fog that interacts with the light coming
  5818. from light sources. Beams of light become visible and objects
  5819. will cast shadows into the fog.
  5820.  
  5821. Last but not least you can add a rainbow to your scene.
  5822.  
  5823.  
  5824. 2.9.1     The Background
  5825. The background feature is used to assign a color to all rays that
  5826. don't hit any object. This is done in the following way.
  5827.  
  5828.   camera {
  5829.     location <0, 0, -10>
  5830.     look_at <0, 0, 0>
  5831.   }
  5832.   background { color rgb <0.2, 0.2, 0.3> }
  5833.   sphere { 0, 1
  5834.     pigment { color rgb <0.8, 0.5, 0.2> }
  5835.   }
  5836. The background color will be visible if a sky sphere is used and
  5837. if some translucency remains after all sky sphere pigment layers
  5838. are processed.
  5839.  
  5840.  
  5841. 2.9.2     The Sky Sphere
  5842. The sky_sphere can be used to easily create a cloud covered sky,
  5843. a nightly star sky or whatever sky you have in mind.
  5844.  
  5845. In the following examples we'll start with a very simple sky
  5846. sphere that will get more and more complex as we add new features
  5847. to it.
  5848.  
  5849.  
  5850. 2.9.2.1   Creating a Sky with a Color Gradient
  5851. Beside the single color sky sphere that is covered with the
  5852. background feature the simplest sky sphere is a color gradient.
  5853.  
  5854. You may have noticed that the color of the sky varies with the
  5855. angle to the earth's surface normal. If you look straight up the
  5856. sky normally has a much deeper blue than it has at the horizon.
  5857.  
  5858. We want to model this effect using the sky sphere as shown in the
  5859. scene below (skysph1.pov).
  5860.  
  5861.   #include "colors.inc"
  5862.   camera {
  5863.     location <0, 1, -4>
  5864.     look_at <0, 2, 0>
  5865.     angle 80
  5866.   }
  5867.   light_source { <10, 10, -10> White }
  5868.   sphere { 2*y, 1
  5869.     pigment { color rgb <1, 1, 1> }
  5870.     finish { ambient 0.2 diffuse 0 reflection 0.6 }
  5871.   }
  5872.   sky_sphere {
  5873.     pigment {
  5874.       gradient y
  5875.       color_map {
  5876.         [0 color Red]
  5877.         [1 color Blue]
  5878.       }
  5879.       scale 2
  5880.       translate -1
  5881.     }
  5882.   }
  5883. The interesting part is the sky sphere statement. It contains a
  5884. pigment that describe the look of the sky sphere. We want to
  5885. create a color gradient along the viewing angle measured against
  5886. the earth's surface normal. Since the ray direction vector is
  5887. used to calculate the pigment colors we have to use the y-
  5888. gradient.
  5889.  
  5890. The scale and translate transformation are used to map the points
  5891. derived from the direction vector to the right range. Without
  5892. those transformations the pattern would be repeated twice on the
  5893. sky sphere. The scale statement is used to avoid the repetition
  5894. and the translate -1 statement moves the color at index zero to
  5895. the bottom of the sky sphere (that's the point of the sky sphere
  5896. you'll see if you look straight down).
  5897.  
  5898. After this transformation the color entry at position 0 will be
  5899. at the bottom of the sky sphere, i. e. below us, and the color at
  5900. position 1 will be at the top, i. e. above us.
  5901.  
  5902. The colors for all other positions are interpolated between those
  5903. two colors as you can see in the resulting image.
  5904.  
  5905.                                 
  5906.                   A simple gradient sky sphere.
  5907. If you want to start one of the colors at a specific angle you'll
  5908. first have to convert the angle to a color map index. This is
  5909. done by using the formula
  5910.  
  5911.   color_map_index = (1 - cos(angle)) / 2
  5912. where the angle is measured against the negated earth's surface
  5913. normal. This is the surface normal pointing towards the center of
  5914. the earth. An angle of 0 degrees describes the point below us
  5915. while an angle of 180 degrees represents the zenith.
  5916.  
  5917. In POV-Ray you first have to convert the degree value to radian
  5918. values as it is shown in the following example.
  5919.  
  5920.   sky_sphere {
  5921.     pigment {
  5922.       gradient y
  5923.       color_map {
  5924.         [(1-cos(radians( 30)))/2 color Red]
  5925.         [(1-cos(radians(120)))/2 color Blue]
  5926.       }
  5927.       scale 2
  5928.       translate -1
  5929.     }
  5930.   }
  5931. This scene uses a color gradient that starts with a red color at
  5932. 30 degrees and blends into the blue color at 120 degrees. Below
  5933. 30 degrees everything is red while above 120 degrees all is blue.
  5934.  
  5935.  
  5936. 2.9.2.2   Adding the Sun
  5937. In the following example we will create a sky with a red sun
  5938. surrounded by a red color halo that blends into the dark blue
  5939. night sky. We'll do this using only the sky sphere feature.
  5940.  
  5941. The sky sphere we use is shown below. A ground plane is also
  5942. added for greater realism (skysph2.pov).
  5943.  
  5944.   sky_sphere {
  5945.     pigment {
  5946.       gradient y
  5947.       color_map {
  5948.         [0.000 0.002 color rgb <1.0, 0.2, 0.0>
  5949.                      color rgb <1.0, 0.2, 0.0>]
  5950.         [0.002 0.200 color rgb <0.8, 0.1, 0.0>
  5951.                      color rgb <0.2, 0.2, 0.3>]
  5952.       }
  5953.       scale 2
  5954.       translate -1
  5955.     }
  5956.     rotate -135*x
  5957.   }
  5958.   plane { y, 0
  5959.     pigment { color Green }
  5960.     finish { ambient .3 diffuse .7 }
  5961.   }
  5962. The gradient pattern and the transformation inside the pigment
  5963. are the same as in the example in the previous section.
  5964.  
  5965. The color map consists of three colors. A bright, slightly
  5966. yellowish red that is used for the sun, a darker red for the halo
  5967. and a dark blue for the night sky. The sun's color covers only a
  5968. very small portion of the sky sphere because we don't want the
  5969. sun to become too big. The color is used at the color map values
  5970. 0.000 and 0.002 to get a sharp contrast at value 0.002 (we don't
  5971. want the sun to blend into the sky). The darker red color used
  5972. for the halo blends into the dark blue sky color from value 0.002
  5973. to 0.200. All values above 0.200 will reveal the dark blue sky.
  5974.  
  5975. The rotate -135*x statement is used to rotate the sun and the
  5976. complete sky sphere to its final position. Without this rotation
  5977. the sun would be at 0 degrees, i.e. right below us.
  5978.  
  5979.                                 
  5980.                A red sun descends into the night.
  5981. Looking at the resulting image you'll see what impressive effects
  5982. you can achieve with the sky sphere.
  5983.  
  5984.  
  5985. 2.9.2.3   Adding Some Clouds
  5986. To further improve our image we want to add some clouds by adding
  5987. a second pigment. This new pigment uses the bozo pattern to
  5988. create some nice clouds. Since it lays on top of the other
  5989. pigment it needs some transparent colors in the color map (look
  5990. at entries 0.5 to 1.0).
  5991.  
  5992.   sky_sphere {
  5993.     pigment {
  5994.       gradient y
  5995.       color_map {
  5996.         [0.000 0.002 color rgb <1.0, 0.2, 0.0>
  5997.                      color rgb <1.0, 0.2, 0.0>]
  5998.         [0.002 0.200 color rgb <0.8, 0.1, 0.0>
  5999.                      color rgb <0.2, 0.2, 0.3>]
  6000.       }
  6001.       scale 2
  6002.       translate -1
  6003.     }
  6004.     pigment {
  6005.       bozo
  6006.       turbulence 0.65
  6007.       octaves 6
  6008.       omega 0.7
  6009.       lambda 2
  6010.       color_map {
  6011.           [0.0 0.1 color rgb <0.85, 0.85, 0.85>
  6012.                    color rgb <0.75, 0.75, 0.75>]
  6013.           [0.1 0.5 color rgb <0.75, 0.75, 0.75>
  6014.                    color rgbt <1, 1, 1, 1>]
  6015.           [0.5 1.0 color rgbt <1, 1, 1, 1>
  6016.                    color rgbt <1, 1, 1, 1>]
  6017.       }
  6018.       scale <0.2, 0.5, 0.2>
  6019.     }
  6020.     rotate -135*x
  6021.   }
  6022.                                 
  6023.                 A cloudy sky with a setting sun.
  6024. The sky sphere has one drawback as you might notice when looking
  6025. at the final image (skysph3.pov). The sun doesn't emit any light
  6026. and the clouds will not cast any shadows. If you want to have
  6027. clouds that cast shadows you'll have to use a real, large sphere
  6028. with an appropriate texture and a light source somewhere outside
  6029. the sphere.
  6030.  
  6031.  
  6032. 2.9.3     The Fog
  6033. You can use the fog feature to add fog of two different types to
  6034. your scene: constant fog and ground fog. The constant fog has a
  6035. constant density everywhere while the ground fog's density
  6036. decreases as you move upwards.
  6037.  
  6038. The usage of both fog types will be described in the next
  6039. sections in detail.
  6040.  
  6041.  
  6042. 2.9.3.1   A Constant Fog
  6043. The simplest fog type is the constant fog that has a constant
  6044. density in all locations. It is specified by a distance keyword
  6045. which actually describes the fog's density and a fog color.
  6046.  
  6047. The distance value determines the distance at which 36.8% of the
  6048. background are still visible (for a more detailed explanation of
  6049. how the fog is calculated read the reference section "Fog").
  6050.  
  6051. The fog color can be used to create anything from a pure white to
  6052. a red, blood-colored fog. You can also use a black fog to
  6053. simulate the effect of a limited range of vision.
  6054.  
  6055. The following example will show you how to add fog to a simple
  6056. scene (fog1.pov).
  6057.  
  6058.   #include "colors.inc"
  6059.   camera {
  6060.     location  <0, 20, -100>
  6061.   }
  6062.   background { color SkyBlue }
  6063.   plane { y, -10
  6064.     pigment {
  6065.       checker color Yellow color Green
  6066.       scale 20
  6067.     }
  6068.   }
  6069.   sphere { <0, 25, 0>, 40
  6070.     pigment { Red }
  6071.     finish { phong 1.0 phong_size 20 }
  6072.   }
  6073.   sphere { <-100, 150, 200>,  20
  6074.     pigment { Green }
  6075.     finish { phong 1.0 phong_size 20 }
  6076.   }
  6077.   sphere { <100, 25, 100>, 30
  6078.     pigment { Blue }
  6079.     finish { phong 1.0 phong_size 20 }
  6080.   }
  6081.   light_source { <100, 120, 40> color White}
  6082.   fog {
  6083.     distance 150
  6084.     color rgb<0.3, 0.5, 0.2>
  6085.   }
  6086.                                 
  6087.                          A foggy scene.
  6088. According to their distance the spheres in this scene more or
  6089. less vanish in the greenish fog we used, as does the checkerboard
  6090. plane.
  6091.  
  6092.  
  6093. 2.9.3.2   Setting a Minimum Translucency
  6094. If you want to make sure that the background does not completely
  6095. vanish in the fog you can set the transmittance channel of the
  6096. fog's color to the amount of background you always want to be
  6097. visible.
  6098.  
  6099. Using as transmittance value of 0.2 as in
  6100.  
  6101.   fog {
  6102.     distance 150
  6103.     color rgbt<0.3, 0.5, 0.2, 0.2>
  6104.   }
  6105. the fog's translucency never drops below 20% as you can see in
  6106. the resulting image (fog2.pov).
  6107.  
  6108.                                 
  6109. Adding a translucency threshold you make sure that the background
  6110.                         does not vanish.
  6111.  
  6112. 2.9.3.3   Creating a Filtering Fog
  6113. The greenish fog we have used so far doesn't filter the light
  6114. passing through it. All it does is to diminish the light's
  6115. intensity. We can change this by using a non-zero filter channel
  6116. in the fog's color (fog3.pov).
  6117.  
  6118.   fog {
  6119.     distance 150
  6120.     color rgbf<0.3, 0.5, 0.2, 1.0>
  6121.   }
  6122. The filter value determines the amount of light that is filtered
  6123. by the fog. In our example 100% of the light passing through the
  6124. fog will be filtered by the fog. If we had used a value of 0.7
  6125. only 70% of the light would have been filtered. The remaining 30%
  6126. would have passed unfiltered.
  6127.  
  6128.                                 
  6129.                         A filtering fog.
  6130. You'll notice that the intensity of the objects in the fog is not
  6131. only diminished due to the fog's color but that the colors are
  6132. actually influenced by the fog. The red and especially the blue
  6133. sphere got a green hue.
  6134.  
  6135.  
  6136. 2.9.3.4   Adding Some Turbulence to the Fog
  6137. In order to make our somewhat boring fog a little bit more
  6138. interesting we can add some turbulence, making it look like it
  6139. had a non-constant density (fog4.pov).
  6140.  
  6141.   fog {
  6142.     distance 150
  6143.     color rgbf<0.3, 0.5, 0.2, 1.0>
  6144.     turbulence 0.2
  6145.     turb_depth 0.3
  6146.   }
  6147.                                 
  6148.      Adding some turbulence makes the fog more interesting.
  6149. The turbulence keyword is used to specify the amount of
  6150. turbulence used while the turb_depth value is used to move the
  6151. point at which the turbulence value is calculated along the
  6152. viewing ray. Values near zero move the point to the viewer while
  6153. values near one move it to the intersection point (the default
  6154. value is 0.5). This parameter can be used to avoid noise that may
  6155. appear in the fog due to the turbulence (this normally happens at
  6156. very far away intersection points, especially if no intersection
  6157. occurs, i. e. the background is hit). If this happens just lower
  6158. the turb_depth value until the noise vanishes.
  6159.  
  6160. You should keep in mind that the actual density of the fog does
  6161. not change. Only the distance-based attenuation value of the fog
  6162. is modified by the turbulence value at a point along the viewing
  6163. ray.
  6164.  
  6165.  
  6166. 2.9.3.5   Using Ground Fog
  6167. The much more interesting and flexible fog type is the ground
  6168. fog, which is selected with the fog_type statement. It's
  6169. appearance is described with the fog_offset and fog_alt keywords.
  6170. The fog_offset specifies the height, i. e. y value, below which
  6171. the fog has a constant density of one. The fog_alt keyword
  6172. determines how fast the density of the fog will approach zero as
  6173. one moves along the y axis. At a height of fog_offset+fog_alt the
  6174. fog will have a density of 25%.
  6175.  
  6176. The following example (fog5.pov) uses a ground fog which has a
  6177. constant density below y=25 (the center of the red sphere) and
  6178. quickly falls off for increasing altitudes.
  6179.  
  6180.   fog {
  6181.     distance 150
  6182.     color rgbf<0.3, 0.5, 0.2, 1.0>
  6183.     fog_type 2
  6184.     fog_offset 25
  6185.     fog_alt 1
  6186.   }
  6187.                                 
  6188.     The ground fog only covers the lower parts of the world.'
  6189.  
  6190. 2.9.3.6   Using Multiple Layers of Fog
  6191. It is possible to use several layers of fog by using more than
  6192. one fog statement in your scene file. This is quite useful if you
  6193. want to get nice effects using turbulent ground fogs. You could
  6194. add up several, differently colored fogs to create an eerie scene
  6195. for example.
  6196.  
  6197. Just try the following example (fog6.pov).
  6198.  
  6199.   fog {
  6200.     distance 150
  6201.     color rgb<0.3, 0.5, 0.2>
  6202.     fog_type 2
  6203.     fog_offset 25
  6204.     fog_alt 1
  6205.     turbulence 0.1
  6206.     turb_depth 0.2
  6207.   }
  6208.   fog {
  6209.     distance 150
  6210.     color rgb<0.5, 0.1, 0.1>
  6211.     fog_type 2
  6212.     fog_offset 15
  6213.     fog_alt 4
  6214.     turbulence 0.2
  6215.     turb_depth 0.2
  6216.   }
  6217.   fog {
  6218.     distance 150
  6219.     color rgb<0.1, 0.1, 0.6>
  6220.     fog_type 2
  6221.     fog_offset 10
  6222.     fog_alt 2
  6223.   }
  6224.                                 
  6225. Quite nice results can be achieved using multiple layers of fog.
  6226. You can combine constant density fogs, ground fogs, filtering
  6227. fogs, non-filtering fogs, fogs with a translucency threshold,
  6228. etc.
  6229.  
  6230.  
  6231. 2.9.3.7   Fog and Hollow Objects
  6232. Whenever you use the fog feature and the camera is inside a non-
  6233. hollow object you won't get any fog effects. For a detailed
  6234. explanation why this happens see "Empty and Solid Objects".
  6235.  
  6236. In order to avoid this problem you have to make all those objects
  6237. hollow by either making sure the camera is outside these objects
  6238. (using the inverse keyword) or by adding the hollow to them
  6239. (which is much easier).
  6240.  
  6241.  
  6242. 2.9.4     The Rainbow
  6243. The rainbow feature can be used to create rainbows and maybe
  6244. other more strange effects. The rainbow is a fog like effect that
  6245. is restricted to a cone-like volume.
  6246.  
  6247.  
  6248. 2.9.4.1   Starting With a Simple Rainbow
  6249. The rainbow is specified with a lot of parameters: the angle
  6250. under which it is visible, the width of the color band, the
  6251. direction of the incoming light, the fog-like distance based
  6252. particle density and last but not least the color map to be used.
  6253.  
  6254. The size and shape of the rainbow are determined by the angle and
  6255. width keywords. The direction keyword is used to set the
  6256. direction of the incoming light, thus setting the rainbow's
  6257. position. The rainbow is visible when the angle between the
  6258. direction vector and the incident light direction is larger than
  6259. angle-width/2 and smaller than angle+width/2.
  6260.  
  6261. The incoming light is the virtual light source that is
  6262. responsible for the rainbow. There needn't be a real light source
  6263. to create the rainbow effect.
  6264.  
  6265. The rainbow is a fog-like effect, i.e. the rainbow's color is
  6266. mixed with the background color based on the distance to the
  6267. intersection point. If you choose small distance values the
  6268. rainbow will be visible on objects, not just in the background.
  6269. You can avoid this by using a very large distance value.
  6270.  
  6271. The color map is the crucial part of the rainbow since it
  6272. contains all the colors that normally can be seen in a rainbow.
  6273. The color of the innermost color band is taken from the color map
  6274. entry 0 while the outermost band is take from entry 1. You should
  6275. note that due to the limited color range any monitor can display
  6276. it is impossible to create a real rainbow. There are just some
  6277. colors that you cannot display.
  6278.  
  6279. The filter channel of the rainbow's color map is used in the same
  6280. way as with fogs. It determines how much of the light passing
  6281. through the rainbow is filtered by the color.
  6282.  
  6283. The following example shows a simple scene with a ground plane,
  6284. three spheres and a somewhat exaggerated rainbow (rainbow1.pov).
  6285.  
  6286.   #include "colors.inc"
  6287.   camera {
  6288.     location <0, 20, -100>
  6289.     look_at <0, 25, 0>
  6290.     angle 80
  6291.   }
  6292.   background { color SkyBlue }
  6293.   plane { y, -10 pigment { color Green } }
  6294.   light_source {<100, 120, 40> color White}
  6295.   // declare rainbow's colors
  6296.   #declare r_violet1 = color rgbf<1.0, 0.5, 1.0, 1.0>;
  6297.   #declare r_violet2 = color rgbf<1.0, 0.5, 1.0, 0.8>;
  6298.   #declare r_indigo  = color rgbf<0.5, 0.5, 1.0, 0.8>;
  6299.   #declare r_blue    = color rgbf<0.2, 0.2, 1.0, 0.8>;
  6300.   #declare r_cyan    = color rgbf<0.2, 1.0, 1.0, 0.8>;
  6301.   #declare r_green   = color rgbf<0.2, 1.0, 0.2, 0.8>;
  6302.   #declare r_yellow  = color rgbf<1.0, 1.0, 0.2, 0.8>;
  6303.   #declare r_orange  = color rgbf<1.0, 0.5, 0.2, 0.8>;
  6304.   #declare r_red1    = color rgbf<1.0, 0.2, 0.2, 0.8>;
  6305.   #declare r_red2    = color rgbf<1.0, 0.2, 0.2, 1.0>;
  6306.   // create the rainbow
  6307.   rainbow {
  6308.     angle 42.5
  6309.     width 5
  6310.     distance 1.0e7
  6311.     direction <-0.2, -0.2, 1>
  6312.     jitter 0.01
  6313.     color_map {
  6314.       [0.000  color r_violet1]
  6315.       [0.100  color r_violet2]
  6316.       [0.214  color r_indigo]
  6317.       [0.328  color r_blue]
  6318.       [0.442  color r_cyan]
  6319.       [0.556  color r_green]
  6320.       [0.670  color r_yellow]
  6321.       [0.784  color r_orange]
  6322.       [0.900  color r_red1]
  6323.     }
  6324.   }
  6325. Some irregularity is added to the color bands using the jitter
  6326. keyword.
  6327.  
  6328.                                 
  6329.                        A colorful rainbow.
  6330. The rainbow in our sample is much too bright. You'll never see a
  6331. rainbow like this in reality. You can decrease the rainbow's
  6332. colors by decreasing the RGB values in the color map.
  6333.  
  6334.  
  6335. 2.9.4.2   Increasing the Rainbow's Translucency
  6336. The result we have so far looks much too bright. Just reducing
  6337. the rainbow's color helps but it's much better to increase the
  6338. translucency of the rainbow because it is more realistic if the
  6339. background is visible through the rainbow.
  6340.  
  6341. We can use the transmittance channel of the colors in the color
  6342. map to specify a minimum translucency, just like we did with the
  6343. fog. To get realistic results we have to use very large
  6344. transmittance values as you can see in the following example
  6345. (rainbow2.pov).
  6346.  
  6347.   rainbow {
  6348.     angle 42.5
  6349.     width 5
  6350.     distance 1.0e7
  6351.     direction <-0.2, -0.2, 1>
  6352.     jitter 0.01
  6353.     color_map {
  6354.       [0.000  color r_violet1 transmit 0.98]
  6355.       [0.100  color r_violet2 transmit 0.96]
  6356.       [0.214  color r_indigo  transmit 0.94]
  6357.       [0.328  color r_blue    transmit 0.92]
  6358.       [0.442  color r_cyan    transmit 0.90]
  6359.       [0.556  color r_green   transmit 0.92]
  6360.       [0.670  color r_yellow  transmit 0.94]
  6361.       [0.784  color r_orange  transmit 0.96]
  6362.       [0.900  color r_red1    transmit 0.98]
  6363.     }
  6364.   }
  6365. The transmittance values increase at the outer bands of the
  6366. rainbow to make it softly blend into the background.
  6367.  
  6368.                                 
  6369.                  A much more realistic rainbow.
  6370. The resulting image looks much more realistic than our first
  6371. rainbow.
  6372.  
  6373.  
  6374. 2.9.4.3   Using a Rainbow Arc
  6375. Currently our rainbow has a circular shape, even though most of
  6376. it is hidden below the ground plane. You can easily create a
  6377. rainbow arc by using the arc_angle keyword with an angle below
  6378. 360 degrees.
  6379.  
  6380. If you use arc_angle 120 for example you'll get a rainbow arc
  6381. that abruptly vanishes at the arc's ends. This does not look
  6382. good. To avoid this the falloff_angle keyword can be used to
  6383. specify a region where the arc smoothly blends into the
  6384. background.
  6385.  
  6386. As explained in the rainbow's reference section (see "Rainbow")
  6387. the arc extends from -arc_angle/2 to arc_angle/2 while the
  6388. blending takes place from -arc_angle/2 to -falloff_angle/2 and
  6389. falloff_angle/2 to arc_angle/2. This is the reason why the
  6390. falloff_angle has to be smaller or equal to the arc_angle.
  6391.  
  6392. In the following examples we use an 120 degrees arc with a 45
  6393. degree falloff region on both sides of the arc (rainbow3.pov).
  6394.  
  6395.   rainbow {
  6396.     angle 42.5
  6397.     width 5
  6398.     arc_angle 120
  6399.     falloff_angle 30
  6400.     distance 1.0e7
  6401.     direction <-0.2, -0.2, 1>
  6402.     jitter 0.01
  6403.     color_map {
  6404.       [0.000  color r_violet1 transmit 0.98]
  6405.       [0.100  color r_violet2 transmit 0.96]
  6406.       [0.214  color r_indigo  transmit 0.94]
  6407.       [0.328  color r_blue    transmit 0.92]
  6408.       [0.442  color r_cyan    transmit 0.90]
  6409.       [0.556  color r_green   transmit 0.92]
  6410.       [0.670  color r_yellow  transmit 0.94]
  6411.       [0.784  color r_orange  transmit 0.96]
  6412.       [0.900  color r_red1    transmit 0.98]
  6413.     }
  6414.   }
  6415. The arc angles are measured against the rainbows up direction
  6416. which can be specified using the up keyword. By default the up
  6417. direction is the y-axis.
  6418.  
  6419.                                 
  6420.                          A rainbow arc.
  6421. We finally have a realistic looking rainbow arc.
  6422.  
  6423.  
  6424. 2.9.5     Animation
  6425. There are a number of programs available that will take a series
  6426. of still image files (such as POV-Ray outputs) and assemble them
  6427. into animations.  Such programs can produce AVI, MPEG, FLI/FLC,
  6428. QuickTime, or even animated GIF files (for use on the World Wide
  6429. Web). The trick, therefore, is how to produce the frames. That,
  6430. of course, is where POV-Ray comes in. In earlier versions
  6431. producing an animation series was no joy, as everything had to be
  6432. done manually. We had to set the clock variable, and handle
  6433. producing unique file names for each individual frame by hand. We
  6434. could achieve some degree of automation by using batch files or
  6435. similar scripting devices, but still, We had to set it all up by
  6436. hand, and that was a lot of work (not to mention frustration...
  6437. imagine forgetting to set the individual file names and coming
  6438. back 24 hours later to find each frame had overwritten the last).
  6439.  
  6440. Now, at last, with POV-Ray 3, there is a better way. We no longer
  6441. need a separate batch script or external sequencing programs,
  6442. because a few simple settings in our INI file (or on the command
  6443. line) will activate an internal animation sequence which will
  6444. cause POV-Ray to automatically handle the animation loop details
  6445. for us.
  6446.  
  6447. Actually, there are two halves to animation support: those
  6448. settings we put in the INI file (or on the command line), and
  6449. those code modifications we work into our scene description file.
  6450. If we've already worked with animation in previous versions of
  6451. POV-Ray, we can probably skip ahead to the section "INI File
  6452. Settings" below. Otherwise, let's start with basics. Before we
  6453. get to how to activate the internal animation loop, let's look at
  6454. a couple examples of how a couple of keywords can set up our code
  6455. to describe the motions of objects over time.
  6456.  
  6457.  
  6458. 2.9.5.1   The Clock Variable: Key To It All
  6459. POV-Ray supports an automatically declared floating point
  6460. variable identified as clock (all lower case). This is the key to
  6461. making image files that can be automated. In command line
  6462. operations, the clock variable is set using the +k switch. For
  6463. example, +k3.4 from the command line would set the value of clock
  6464. to 3.4. The same could be accomplished from the INI file using
  6465. Clock=3.4 in an INI file.
  6466.  
  6467. If we don't set clock for anything, and the animation loop is not
  6468. used (as will be described a little later) the clock variable is
  6469. still there - it's just set for the default value of 0.0, so it
  6470. is possible to set up some POV code for the purpose of animation,
  6471. and still render it as a still picture during the object/world
  6472. creation stage of our project.
  6473.  
  6474. The simplest example of using this to our advantage would be
  6475. having an object which is travelling at a constant rate, say,
  6476. along the x-axis. We would have the statement
  6477.  
  6478.   translate <clock, 0, 0>
  6479. in our object's declaration, and then have the animation loop
  6480. assign progressively higher values to clock. And that's fine, as
  6481. long as only one element or aspect of our scene is changing, but
  6482. what happens when we want to control multiple changes in the same
  6483. scene simultaneously?
  6484.  
  6485. The secret here is to use normalized clock values, and then make
  6486. other variables in your scene proportional to clock. That is,
  6487. when we set up our clock, (we're getting to that, patience!) have
  6488. it run from 0.0 to 1.0, and then use that as a multiplier to some
  6489. other values. That way, the other values can be whatever we need
  6490. them to be, and clock can be the same 0 to 1 value for every
  6491. application. Let's look at a (relatively) simple example
  6492.  
  6493.   #include "colors.inc"
  6494.   camera {
  6495.     location <0, 3, -6>
  6496.     look_at <0, 0, 0>
  6497.   }
  6498.   light_source { <20, 20, -20> color White }
  6499.   plane { y, 0
  6500.     pigment { checker color White color Black }
  6501.   }
  6502.   sphere { <0, 0, 0> , 1
  6503.     pigment {
  6504.       gradient x
  6505.       color_map {
  6506.         [0.0 Blue  ]
  6507.         [0.5 Blue  ]
  6508.         [0.5 White ]
  6509.         [1.0 White ]
  6510.       }
  6511.       scale .25
  6512.     }
  6513.     rotate <0, 0, -clock*360>
  6514.     translate <-pi, 1, 0>
  6515.     translate <2*pi*clock, 0, 0>
  6516.   }
  6517. Assuming that a series of frames is run with the clock
  6518. progressively going from 0.0 to 1.0, the above code will produce
  6519. a striped ball which rolls from left to right across the screen.
  6520. We have two goals here:
  6521.  
  6522.  
  6523. 1.  Translate the ball from point A to point B, and,
  6524. 2.  Rotate the ball in exactly the right proportion to its linear
  6525.   movement to imply that it is rolling -- not gliding -- to its
  6526.   final position.
  6527. Taking the second goal first, we start with the sphere at the
  6528. origin, because anywhere else and rotation will cause it to orbit
  6529. the origin instead of rotating. Throughout the course of the
  6530. animation, the ball will turn one complete 360 degree turn.
  6531. Therefore, we used the formula, 360*clock to determine the
  6532. rotation in each frame. Since clock runs 0 to 1, the rotation of
  6533. the sphere runs from 0 degrees through 360.
  6534.  
  6535. Then we used the first translation to put the sphere at its
  6536. initial starting point. Remember, we couldn't have just declared
  6537. it there, or it would have orbited the origin, so before we can
  6538. meet our other goal (translation), we have to compensate by
  6539. putting the sphere back where it would have been at the start.
  6540. After that, we re-translate the sphere by a clock relative
  6541. distance, causing it to move relative to the starting point.
  6542. We've chosen the formula of 2*pi* r*clock (the widest
  6543. circumference of the sphere times current clock value) so that it
  6544. will appear to move a distance equal to the circumference of the
  6545. sphere in the same time that it rotates a complete 360 degrees.
  6546. In this way, we've synchronized the rotation of the sphere to its
  6547. translation, making it appear to be smoothly rolling along the
  6548. plane.
  6549.  
  6550. Besides allowing us to coordinate multiple aspects of change over
  6551. time more cleanly, mathematically speaking, the other good reason
  6552. for using normalized clock values is that it will not matter
  6553. whether we are doing a ten frame animated GIF, or a three hundred
  6554. frame AVI. Values of the clock are proportioned to the number of
  6555. frames, so that same POV code will work without regard to how
  6556. long the frame sequence is. Our rolling ball will still travel
  6557. the exact same amount no matter how many frames our animation
  6558. ends up with.
  6559.  
  6560.  
  6561. 2.9.5.2   Clock Dependant Variables And Multi-Stage Animations
  6562. Okay, what if we wanted the ball to roll left to right for the
  6563. first half of the animation, then change direction 135 degrees
  6564. and roll right to left, and toward the back of the scene. We
  6565. would need to make use of POV-Ray's new conditional rendering
  6566. directives, and test the clock value to determine when we reach
  6567. the halfway point, then start rendering a different clock
  6568. dependant sequence. But our goal, as above, it to be working in
  6569. each stage with a variable in the range of 0 to 1 (normalized)
  6570. because this makes the math so much cleaner to work with when we
  6571. have to control multiple aspects during animation. So let's
  6572. assume we keep the same camera, light, and plane, and let the
  6573. clock run from 0 to 2! Now, replace the single sphere declaration
  6574. with the following...
  6575.  
  6576.   #if ( clock <= 1 )
  6577.     sphere { <0, 0, 0> , 1
  6578.       pigment {
  6579.         gradient x
  6580.         color_map {
  6581.           [0.0 Blue  ]
  6582.           [0.5 Blue  ]
  6583.           [0.5 White ]
  6584.           [1.0 White ]
  6585.         }
  6586.         scale .25
  6587.       }
  6588.       rotate <0, 0, -clock*360>
  6589.       translate <-pi, 1, 0>
  6590.       translate <2*pi*clock, 0, 0>
  6591.     }
  6592.   #else
  6593.     // (if clock is > 1, we're on the second phase)
  6594.     // we still want to work with  a value from 0 - 1
  6595.     #declare ElseClock = clock - 1;
  6596.     sphere { <0, 0, 0> , 1
  6597.       pigment {
  6598.         gradient x
  6599.         color_map {
  6600.           [0.0 Blue  ]
  6601.           [0.5 Blue  ]
  6602.           [0.5 White ]
  6603.           [1.0 White ]
  6604.         }
  6605.         scale .25
  6606.       }
  6607.       rotate <0, 0, ElseClock*360>
  6608.       translate <-2*pi*ElseClock, 0, 0>
  6609.       rotate <0, 45, 0>
  6610.       translate <pi, 1, 0>
  6611.     }
  6612.   #end
  6613. If we spotted the fact that this will cause the ball to do an
  6614. unrealistic snap turn when changing direction, bonus points for
  6615. us - we're a born animator. However, for the simplicity of the
  6616. example, let's ignore that for now. It will be easy enough to fix
  6617. in the real world, once we examine how the existing code works.
  6618.  
  6619. All we did differently was assume that the clock would run 0 to
  6620. 2, and that we wanted to be working with a normalized value
  6621. instead. So when the clock goes over 1.0, POV assumes the second
  6622. phase of the journey has begun, and we declare a new variable
  6623. Elseclock which we make relative to the original built in clock,
  6624. in such a way that while clock is going 1 to 2, Elseclock is
  6625. going 0 to 1. So, even though there is only one clock, there can
  6626. be as many additional variables as we care to declare (and have
  6627. memory for), so even in fairly complex scenes, the single clock
  6628. variable can be made the common coordinating factor which
  6629. orchestrates all other motions.
  6630.  
  6631.  
  6632. 2.9.5.3   The Phase Keyword
  6633. There is another keyword we should know for purposes of
  6634. animations: the phase keyword. The phase keyword can be used on
  6635. many texture elements, especially those that can take a color,
  6636. pigment, normal or texture map.  Remember the form that these
  6637. maps take. For example:
  6638.  
  6639.   color_map {
  6640.     [0.00 White ]
  6641.     [0.25 Blue ]
  6642.     [0.76 Green ]
  6643.     [1.00 Red ]
  6644.   }
  6645. The floating point value to the left inside each set of brackets
  6646. helps POV-Ray to map the color values to various areas of the
  6647. object being textured.  Notice that the map runs cleanly from 0.0
  6648. to 1.0?
  6649.  
  6650. Phase causes the color values to become shifted along the map by
  6651. a floating point value which follows the keyword phase. Now, if
  6652. we are using a normalized clock value already anyhow, we can make
  6653. the variable clock the floating point value associated with
  6654. phase, and the pattern will smoothly shift over the course of the
  6655. animation. Let's look at a common example using a gradient normal
  6656. pattern
  6657.  
  6658.   #include "colors.inc"
  6659.   #include "textures.inc"
  6660.   #background { rgb<0.8, 0.8, 0.8> }
  6661.   camera {
  6662.     location <1.5, 1, -30>
  6663.     look_at <0, 1, 0>
  6664.     angle 10
  6665.   }
  6666.   light_source { <-100, 20, -100> color White }
  6667.   // flag
  6668.   polygon { 5, <0, 0>, <0, 1>, <1, 1>, <1, 0>, <0, 0>
  6669.     pigment { Blue }
  6670.     normal {
  6671.       gradient x
  6672.       phase clock
  6673.       scale <0.2, 1, 1>
  6674.       sine_wave
  6675.     }
  6676.     scale <3, 2, 1>
  6677.     translate <-1.5, 0, 0>
  6678.   }
  6679.   // flagpole
  6680.   cylinder { <-1.5, -4, 0>, <-1.5, 2.25, 0>, 0.05
  6681.     texture { Silver_Metal }
  6682.   }
  6683.   // polecap
  6684.   sphere { <-1.5, 2.25, 0>, 0.1
  6685.     texture { Silver_Metal }
  6686.   }
  6687. Now, here we've created a simple blue flag with a gradient normal
  6688. pattern on it. We've forced the gradient to use a sine-wave type
  6689. wave so that it looks like the flag is rolling back and forth as
  6690. though flapping in a breeze. But the real magic here is that
  6691. phase keyword. It's been set to take the clock variable as a
  6692. floating point value which, as the clock increments slowly toward
  6693. 1.0, will cause the crests and troughs of the flag's wave to
  6694. shift along the x-axis.  Effectively, when we animate the frames
  6695. created by this code, it will look like the flag is actually
  6696. rippling in the wind.
  6697.  
  6698. This is only one, simple example of how a clock dependant phase
  6699. shift can create interesting animation effects. Trying phase will
  6700. all sorts of texture patterns, and it is amazing the range of
  6701. animation effects we can create simply by phase alone, without
  6702. ever actually moving the object.
  6703.  
  6704.  
  6705. 2.9.5.4   Do Not Use Jitter Or Crand
  6706.  One last piece of basic information to save frustration. Because
  6707. jitter is an element of anti-aliasing, we could just as easily
  6708. have mentioned this under the INI file settings section, but
  6709. there are also forms of anti-aliasing used in area lights, and
  6710. the new atmospheric effects of POV-Ray, so now is as good a time
  6711. as any.
  6712.  
  6713. Jitter is a very small amount of random ray perturbation designed
  6714. to diffuse tiny aliasing errors that might not otherwise totally
  6715. disappear, even with intense anti-aliasing. By randomizing the
  6716. placement of erroneous pixels, the error becomes less noticeable
  6717. to the human eye, because the eye and mind are naturally inclined
  6718. to look for regular patterns rather than random distortions.
  6719.  
  6720. This concept, which works fantastically for still pictures, can
  6721. become a nightmare in animations. Because it is random in nature,
  6722. it will be different for each frame we render, and this becomes
  6723. even more severe if we dither the final results down to, say 256
  6724. color animations (such as FLC's). The result is jumping pixels
  6725. all over the scene, but especially concentrated any place where
  6726. aliasing would normally be a problem (e.g., where an infinite
  6727. plane disappears into the distance).
  6728.  
  6729. For this reason, we should always set jitter to off in area
  6730. lights and anti-aliasing options when preparing a scene for an
  6731. animation. The (relatively) small extra measure quality due to
  6732. the use of jitter will be offset by the ocean of jumpies that
  6733. results. This general rule also applies to any truly random
  6734. texture elements, such as crand.
  6735.  
  6736.  
  6737. 2.9.5.5   INI File Settings
  6738. Okay, so we have a grasp of how to code our file for animation.
  6739. We know about the clock variable, user declared clock-relative
  6740. variables, and the phase keyword. We know not to jitter or crand
  6741. when we render a scene, and we're all set build some animations.
  6742. Alright, let's have at it.
  6743.  
  6744. The first concept we'll need to know is the INI file settings,
  6745. Initial_Frame and Final_Frame. These are very handy settings that
  6746. will allow us to render a particular number of frames and each
  6747. with its own unique frame number, in a completely hands free way.
  6748. It is of course, so blindingly simple that it barely needs
  6749. explanation, but here's an example anyway. We just add the
  6750. following lines to our favorite INI file settings
  6751.  
  6752.   Initial_Frame = 1
  6753.   Final_Frame = 20
  6754. and we'll initiate an automated loop that will generate 20 unique
  6755. frames.  The settings themselves will automatically append a
  6756. frame number onto the end of whatever we have set the output file
  6757. name for, thus giving each frame an unique file number without
  6758. having to think about it. Secondly, by default, it will cycle the
  6759. clock variable up from 0 to 1 in increments proportional to the
  6760. number of frames. This is very convenient, since, no matter
  6761. whether we are making a five frame animated GIF or a 300 frame
  6762. MPEG sequence, we will have a clock value which smoothly cycles
  6763. from exactly the same start to exactly the same finish.
  6764.  
  6765. Next, about that clock. In our example with the rolling ball
  6766. code, we saw that sometimes we want the clock to cycle through
  6767. values other than the default of 0.0 to 1.0. Well, when that's
  6768. the case, there are setting for that too.  The format is also
  6769. quite simple. To make the clock run, as in our example, from 0.0
  6770. to 2.0, we would just add to your INI file the lines
  6771.  
  6772.   Initial_Clock = 0.0
  6773.   Final_Clock = 2.0
  6774. Now, suppose we were developing a sequence of 100 frames, and we
  6775. detected a visual glitch somewhere in frames, say 51 to 75. We go
  6776. back over our code and we think we've fixed it. We'd like to
  6777. render just those 25 frames instead of redoing the whole sequence
  6778. from the beginning. What do we change?
  6779.  
  6780. If we said make Initial_Frame = 51, and Final_Frame = 75, we're
  6781. wrong. Even though this would re-render files named with numbers
  6782. 51 through 75, they will not properly fit into our sequence,
  6783. because the clock will begin at its initial value starting with
  6784. frame 51, and cycle to final value ending with frame 75. The only
  6785. time Initial_Frame and Final_Frame should change is if we are
  6786. doing an essentially new sequence that will be appended onto
  6787. existing material.
  6788.  
  6789. If we wanted to look at just 51 through 75 of the original
  6790. animation, we need two new INI settings
  6791.  
  6792.   Subset_Start_Frame = 51
  6793.   Subset_End_Frame = 75
  6794. Added to settings from before, the clock will still cycle through
  6795. its values proportioned from frames 1 to 100, but we will only be
  6796. rendering that part of the sequence from the 51st to the 75th
  6797. frames.
  6798.  
  6799. This should give us a basic idea of how to use animation.
  6800. Although, this introductory tutorial doesn't cover all the
  6801. angles. For example, the last two settings we just saw, subset
  6802. animation, can take fractional values, like 0.5 to 0.75, so that
  6803. the number of actual frames will not change what portion of the
  6804. animation is being rendered. There is also support for efficient
  6805. odd-even field rendering as would be useful for animations
  6806. prepared for display in interlaced playback such as television
  6807. (see the reference section for full details).
  6808.  
  6809. With POV-Ray 3 now fully supporting a complete host of animation
  6810. options, a whole fourth dimension is added to the raytracing
  6811. experience. Whether we are making a FLIC, AVI, MPEG, or simply an
  6812. animated GIF for our web site, animation support takes a lot of
  6813. the tedium out of the process. And don't forget that phase and
  6814. clock can be used to explore the range of numerous texture
  6815. elements, as well as some of the more difficult to master objects
  6816. (hint: the julia fractal for example). So even if we are
  6817. completely content with making still scenes, adding animation to
  6818. our repertoire can greatly enhance our understanding of what POV-
  6819. Ray is capable of. Adventure awaits!
  6820.  
  6821.  
  6822. 3    POV-Ray Options
  6823. The reference section describes all command line switches and INI
  6824. file keywords that are used to set the options of POV-Ray. It is
  6825. supposed to be used as a reference for looking up things. It does
  6826. not contain detailed explanations on how scenes are written or
  6827. how POV-Ray is used. It just explains all features, their syntax,
  6828. applications, limits, drawbacks, etc.
  6829.  
  6830. POV-Ray was originally created as a command-line program for
  6831. operating systems without graphical interfaces, dialog boxes and
  6832. pull-down menus. Most versions of POV-Ray still use command-line
  6833. switches to tell it what to do. This documentation assumes you
  6834. are using the command-line version. If you are using Macintosh,
  6835. MS-Windows or other GUI versions, there will be dialog boxes or
  6836. menus which do the same thing. There is system-specific
  6837. documentation for each system describing the specific commands.
  6838.  
  6839.  
  6840. 3.1  Setting POV-Ray Options
  6841. There are two distinct ways of setting POV-Ray options: command
  6842. line switches and INI file keywords. Both are explained in detail
  6843. in the following sections.
  6844.  
  6845.  
  6846. 3.1.1     Command Line Switches
  6847. Command line switches consist of a + (plus) or - (minus) sign,
  6848. followed by one or more alphabetic characters and possibly a
  6849. numeric value. Here is a typical command line with switches.
  6850.  
  6851.   POVRAY +Isimple.pov +V +W80 +H60
  6852. povray is the name of the program and it is followed by several
  6853. switches. Each switch begins with a plus or minus sign. The +I
  6854. switch with the filename tells POV-Ray what scene file it should
  6855. use as input and +V tells the program to output its status to the
  6856. text screen as it's working. The +W and +H switches set the width
  6857. and height of the image in pixels. This image will be 80 pixels
  6858. wide by 60 pixels high.
  6859.  
  6860. In switches which toggle a feature, the plus turns it on and
  6861. minus turns it off. For example +P turns on the pause for
  6862. keypress   when finished option while -P turns it off. Other
  6863. switches are used to specify values and do not toggle a feature.
  6864. Either plus or minus may be used in that instance. For example
  6865. +W320 sets the width to 320 pixels. You could also use -W320 and
  6866. get the same results.
  6867.  
  6868. Switches may be specified in upper or lower case. They are read
  6869. left to right but in general may be specified in any order. If
  6870. you specify a switch more than once, the previous value is
  6871. generally overwritten with the last specification. The only
  6872. exception is the +L switch for setting library paths. Up to ten
  6873. unique paths may be specified.
  6874.  
  6875. Almost all + or - switches have an equivalent option which can be
  6876. used in an INI file which is described in the next section. A
  6877. detailed description of each switch is given in the option
  6878. reference section.
  6879.  
  6880.  
  6881. 3.1.2     Using INI Files
  6882. Because it is difficult to set more than a few options on a
  6883. command line, you have the ability to put multiple options in one
  6884. or more text files. These initialization files or INI files have
  6885. .ini as their default extension. Previous versions of POV-Ray
  6886. called them default files or DEF files. You may still use
  6887. existing DEF files with this version of POV-Ray.
  6888.  
  6889. The majority of options you use will be stored in INI files. The
  6890. command line switches are recommended for options which you will
  6891. turn off or on frequently as you perform test renderings of a
  6892. scene you are developing. The file povray.ini is automatically
  6893. read if present.  You may specify additional INI files on the
  6894. command-line by simply typing the file name on the command line.
  6895. For example:
  6896.  
  6897.   POVRAY MYOPTS.INI
  6898. If no extension is given, then .ini is assumed. POV-Ray knows
  6899. this is not a switch because it is not preceded by a plus or
  6900. minus. In fact a common error among new users is that they forget
  6901. to put the +I switch before the input file name. Without the
  6902. switch, POV-Ray thinks that the scene file simple.pov is an INI
  6903. file. Don't forget! If no plus or minus precedes a command line
  6904. switch, it is assumed to be an INI file name.
  6905.  
  6906. You may have multiple INI files on the command line along with
  6907. switches. For example:
  6908.  
  6909.   POVRAY MYOPTS +V OTHER
  6910. This reads options from myopts.ini, then sets the +V switch, then
  6911. reads options from other.ini.
  6912.  
  6913. An INI file is a plain ASCII text file with options of the
  6914. form...
  6915.  
  6916.   Option_keyword=VALUE ; Text after semicolon is a comment
  6917. For example the INI equivalent of the switch +Isimple.pov is...
  6918.  
  6919.   Input_File_Name=simple.pov
  6920. Options are read top to bottom in the file but in general may be
  6921. specified in any order. If you specify an option more than once,
  6922. the previous values are generally overwritten with the last
  6923. specification. The only exception is the Library_Path=path
  6924. options. Up to ten unique paths may be specified.
  6925.  
  6926. Almost all INI-style options have equivalent + or - switches. The
  6927. option reference section gives a detailed description of all POV-
  6928. Ray options. It includes both the INI-style settings and the +/-
  6929. switches.
  6930.  
  6931. The INI keywords are not case sensitive. Only one INI option is
  6932. permitted per line of text. You may also include switches in your
  6933. INI file if they are easier for you. You may have multiple
  6934. switches per line but you should not mix switches and INI options
  6935. on the same line. You may nest INI files by simply putting the
  6936. file name on a line by itself with no equals sign after it.
  6937. Nesting may occur up to ten levels deep.
  6938.  
  6939. For example:
  6940.  
  6941.   ; This is a sample INI file. This entire line is a comment.
  6942.   ; Blank lines are permitted.
  6943.   Input_File_Name=simple.pov ;This sets the input file name
  6944.   +W80 +H60 ; Traditional +/- switches are permitted too
  6945.   MOREOPT   ; Read MOREOPT.INI and continue with next line
  6946.   +V        ; Another switch
  6947.   ; That's all folks!
  6948. INI files may have labeled sections so that more than one set of
  6949. options may be stored in a single file. Each section begins with
  6950. a label in [] brackets. For example:
  6951.  
  6952.   ; RES.INI
  6953.   ; This sample INI file is used to set resolution.
  6954.   +W120 +H100  ; This section has no label.
  6955.                ; Select it with "RES"
  6956.   [Low]
  6957.   +W80 +H60    ; This section has a label.
  6958.                ; Select it with "RES[Low]"
  6959.   [Med]
  6960.   +W320 +H200  ; This section has a label.
  6961.                ; Select it with "RES[Med]"
  6962.   [High]
  6963.   +W640 +H480  ; Labels are not case sensitive.
  6964.                ; "RES[high]" works
  6965.   [Really High]
  6966.   +W800 +H600  ; Labels may contain blanks
  6967. When you specify the INI file you should follow it with the
  6968. section label in brackets. For example...
  6969.  
  6970.   POVRAY RES[Med] +Imyfile.pov
  6971. POV-Ray reads res.ini and skips all options until it finds the
  6972. label Med. It processes options after that label until it finds
  6973. another label and then it skips. If no label is specified on the
  6974. command line then only the unlabeled area at the top of the file
  6975. is read. If a label is specified, the unlabeled area is ignored.
  6976.  
  6977. Because a blank space is considered a delimiter for command-line
  6978. switches, POV-Ray has a difficult time reading file names or INI
  6979. labels containing blanks.  The rule is that INI-style options
  6980. allow blanks in INI files but switches do not allow blanks
  6981. whether in INI files or on the command line.  For example:
  6982.  
  6983.  +Imy file.pov               ;doesn't work anywhere
  6984.  Input_File=my file.pov      ;works only in INI file
  6985. To nest INI files which have blanks in the file name or labels
  6986. use the Include_INI option like this:
  6987.  
  6988.   Input_File=my file.pov
  6989.   Include_Ini=my options[this section]
  6990.  
  6991. 3.1.3     Using the POVINI Environment Variable
  6992. The environment variable POVINI is used to specify the location
  6993. and name of a default INI file that is read every time POV-Ray is
  6994. executed. If POVINI is not specified, or if your computer
  6995. platform does not use environment variables, a default INI file
  6996. may be read. If the specified file does not exist, a warning
  6997. message is printed.
  6998.  
  6999. To set the environment variable under MS-DOS you might put the
  7000. following line in your autoexec.bat file...
  7001.  
  7002.   set POVINI=c:\povray3\default.ini
  7003. On most operating systems the sequence of reading options is as
  7004. follows:
  7005.  
  7006.   1.  Read options from default INI file specified by the POVINI
  7007.   environment variable or platform specific INI file.
  7008.   2.  Read switches from command line (this includes reading any
  7009.   specified INI/DEF files).
  7010. The POVRAYOPT environment variable supported by previous POV-Ray
  7011. versions is no longer available.
  7012.  
  7013.  
  7014. 3.2  Options Reference
  7015. As explained in the previous section, options may be specified by
  7016. switches or INI-style options. Almost all INI-style options have
  7017. equivalent  +/ - switches and most switches have equivalent INI-
  7018. style option. The following sections give a detailed description
  7019. of each POV-Ray option. It includes both the INI-style settings
  7020. and the +/ - switches.
  7021.  
  7022. The notation and terminology used is described in the tables
  7023. below.
  7024. Keyword=bool     Turn Keyword on if bool equals true,
  7025.                  yes, on or 1 and    Turn it off if
  7026.                  it is any other value.
  7027. Keyword=true     Do this option if true, yes, on or 1 is
  7028.                specified.
  7029. Keyword=false    Do this option if false, no, off or 0 is
  7030.                specified.
  7031. Keyword=filen  Set Keyword to filename where filename
  7032. ame              is any valid file name. Note: some
  7033.                  options prohibit the use of any of
  7034.                  the above true or false values as a
  7035.                  file name. They are noted in later
  7036.                  sections.
  7037. n              Any integer such as in +W320
  7038. n.n              Any float such as in Clock=3.45
  7039. 0.n              Any float < 1.0 even if it has no leading
  7040.                0
  7041. s                Any string of text
  7042. x or y         Any single character
  7043. path             Any directory name, drive optional, no
  7044.                final path separator ("\" or "/",
  7045.                depending on the operating system)
  7046. Unless otherwise specifically noted, you may assume that either a
  7047. plus or minus sign before a switch will produce the same results.
  7048.  
  7049.  
  7050. 3.2.1     Animation Options
  7051. POV-Ray 3.0 greatly improved its animation capability with the
  7052. addition of an internal animation loop, automatic output file
  7053. name numbering and the ability to shell out to the operating
  7054. system to external utilities which can assemble individual frames
  7055. into an animation. The internal animation loop is simple yet
  7056. flexible. You may still use external programs or batch files to
  7057. create animations without the internal loop as you may have done
  7058. in POV-Ray 2.
  7059.  
  7060.  
  7061. 3.2.1.1   External Animation Loop
  7062. Clock=n.n      Sets clock float identifier
  7063.                to n.n
  7064. +Kn.n          Same as Clock=n.n
  7065. The Clock=n.n option or the +Kn.n switch may be used to pass a
  7066. single float value to the program for basic animation. The value
  7067. is stored in the float identifier clock.  If an object had a
  7068. rotate <0,clock,0> attached then you could rotate the object by
  7069. different amounts over different frames by setting
  7070. +K10.0,+K20.0... etc. on successive renderings. It is up to the
  7071. user to repeatedly invoke POV-Ray with a different Clock value
  7072. and a different Output_File_Name for each frame.
  7073.  
  7074.  
  7075. 3.2.1.2   Internal Animation Loop
  7076. Initial_Frame  Sets initial frame number to
  7077. =n             n
  7078. Final_Frame=n  Sets final frame number to n
  7079. Initial_Clock  Sets initial clock value to
  7080. =n.n           n.n
  7081. Final_Clock=n  Sets final clock value to
  7082. .n             n.n
  7083. +KFIn          Same as Initial_Frame=n
  7084. +KFFn          Same as Final_Frame=n
  7085. +KIn.n         Same as Initial_Clock=n.n
  7086. +KFn.n         Same as Final_Clock=n.n
  7087. The internal animation loop new to POV-Ray 3.0 relieves the user
  7088. of the task of generating complicated sets of batch files to
  7089. invoke POV-Ray multiple times with different settings. While the
  7090. multitude of options may look intimidating, the clever set of
  7091. default values means that you will probably only need to specify
  7092. the Final_Frame=n or the +KFFn option to specify the number of
  7093. frames. All other values may remain at their defaults.
  7094.  
  7095. Any Final_Frame setting other than -1 will trigger POV-Ray's
  7096. internal animation loop. For example Final_Frame=10 or +KFF10
  7097. causes POV-Ray to render your scene 10 times. If you specified
  7098. Output_File_Name=file.tga then each frame would be output as
  7099. file01.tga, file02.tga, file03.tga etc. The number of zero-padded
  7100. digits in the file name depends upon the final frame number. For
  7101. example +KFF100 would generate file001.tga through file100.tga.
  7102. The frame number may encroach upon the file name. On MS-DOS with
  7103. an eight character limit, myscene.pov would render to
  7104. mysce001.tga through mysce100.tga.
  7105.  
  7106. The default Initial_Frame=1 will probably never have to be
  7107. changed. You would only change it if you were assembling a long
  7108. animation sequence in pieces. One scene might run from frame 1 to
  7109. 50 and the next from 51 to 100. The Initial_Frame=n or +KFIn
  7110. option is for this purpose.
  7111.  
  7112. Note that if you wish to render a subset of frames such as 30
  7113. through 40 out of a 1 to 100 animation, you should not change
  7114. Frame_Initial or Frame_Final. Instead you should use the subset
  7115. commands described in section "Subsets of Animation Frames".
  7116.  
  7117. Unlike some animation packages, the action in POV-Ray animated
  7118. scenes does not depend upon the integer frame numbers. Rather you
  7119. should design your scenes based upon the float identifier clock.
  7120. By default, the clock value is 0.0 for the initial frame and 1.0
  7121. for the final frame. All other frames are interpolated between
  7122. these values. For example if your object is supposed to rotate
  7123. one full turn over the course of the animation, you could specify
  7124. rotate 360*clock*y. Then as clock runs from 0.0 to 1.0, the
  7125. object rotates about the y-axis from 0 to 360 degrees.
  7126.  
  7127. The major advantage of this system is that you can render a 10
  7128. frame animation or a 100 frame or 500 frame or 329 frame
  7129. animation yet you still get one full 360 degree rotation. Test
  7130. renders of a few frames work exactly like final renders of many
  7131. frames.
  7132.  
  7133. In effect you define the motion over a continuous float valued
  7134. parameter (the clock) and you take discrete samples at some fixed
  7135. intervals (the frames). If you take a movie or video tape of a
  7136. real scene it works the same way. An object's actual motion
  7137. depends only on time.  It does not depend on the frame rate of
  7138. your camera.
  7139.  
  7140. Many users have already created scenes for POV-Ray 2 that expect
  7141. clock values over a range other than the default 0.0 to 1.0. For
  7142. this reason we provide the Initial_Clock=n.n or +KIn.n and
  7143. Final_Clock=n.n or +KFn.n options. For example to run the clock
  7144. from 25.0 to 75.0 you would specify Initial_Clock=25.0 and
  7145. Final_Clock=75.0. Then the clock would be set to 25.0 for the
  7146. initial frame and 75.0 for the final frame. In-between frames
  7147. would have clock values interpolated from 25.0 through 75.0
  7148. proportionally.
  7149.  
  7150. Users who are accustomed to using frame numbers rather than clock
  7151. values could specify Initial_Clock=1.0 and Final_Clock=10.0 and
  7152. Frame_Final=10 for a 10 frame animation.
  7153.  
  7154. For new scenes, we recommend you do not change the Initial_Clock
  7155. or Final_Clock from their default 0.0 to 1.0 values. If you want
  7156. the clock to vary over a different range than the default 0.0 to
  7157. 1.0, we recommend you handle this inside your scene file as
  7158. follows...
  7159.  
  7160.   #declare Start    = 25.0;
  7161.   #declare End      = 75.0;
  7162.   #declare My_Clock = Start+(End-Start)*clock;
  7163. Then use My_Clock in the scene description. This keeps the
  7164. critical values 25.0 and 75.0 in your .pov file.
  7165.  
  7166. Note that more details concerning the inner workings of the
  7167. animation loop are in the section on shell-out operating system
  7168. commands in section "Shell-out to Operating System".
  7169.  
  7170.  
  7171. 3.2.1.3   Subsets of Animation Frames
  7172.  
  7173. Subset_Start_Frame  Set subset starting frame to
  7174. =n                  n
  7175. Subset_Start_Frame  Set subset starting frame to
  7176. =0.n                n percent
  7177. Subset_End_Frame=n  Set subset ending frame to n
  7178. Subset_End_Frame=0  Set subset ending frame to n
  7179. .n                  percent
  7180. +SFn or +SF0.n      Same as Subset_Start_Frame
  7181. +EFn or +EF0.n      Same as Subset_End_Frame
  7182. When creating a long animation, it may be handy to render only a
  7183. portion of the animation to see what it looks like. Suppose you
  7184. have 100 frames but only want to render frames 30 through 40. If
  7185. you set Initial_Frame=30 and Final_Frame=40 then the clock would
  7186. vary from 0.0 to 1.0 from frames 30 through 40 rather than 0.30
  7187. through 0.40 as it should. Therefore you should leave
  7188. Initial_Frame=1 and Final_Frame=100 and use Subset_Start_Frame=30
  7189. and Subset_End_Frame=40 to selectively render part of the scene.
  7190. POV-Ray will then properly compute the clock values.
  7191.  
  7192. Usually you will specify the subset using the actual integer
  7193. frame numbers however an alternate form of the subset commands
  7194. takes a float value in the range 0.0 <=n.nnn <=1.0 which is
  7195. interpreted as a fraction of the whole animation. For example,
  7196. Subset_Start_Frame=0.333 and Subset_End_Frame=0.667 would render
  7197. the middle 1/3rd of a sequence regardless of the number of
  7198. frames.
  7199.  
  7200.  
  7201. 3.2.1.4   Cyclic Animation
  7202. Cyclic_Animation=b       Turn cyclic animation
  7203. ool                 on/off
  7204. +KC                      Turn cyclic animation
  7205.                     on
  7206. -KC                      Turn cyclic animation
  7207.                     off
  7208. Many computer animation sequences are designed to be run in a
  7209. continuous loop. Suppose you have an object that rotates exactly
  7210. 360 degrees over the course of your animation and you did rotate
  7211. 360*clock*y to do so. Both the first and last frames would be
  7212. identical. Upon playback there would be a brief one frame
  7213. jerkiness. To eliminate this problem you need to adjust the clock
  7214. so that the last frame does not match the first. For example a
  7215. ten frame cyclic animation should not use clock 0.0 to 1.0. It
  7216. should run from 0.0 to 0.9 in 0.1 increments. However if you
  7217. change to 20 frames it should run from 0.0 to 0.95 in 0.05
  7218. increments. This complicates things because you would have to
  7219. change the final clock value every time you changed Final_Frame.
  7220. Setting Cyclic_Animation=on or using +KC will cause POV-Ray to
  7221. automatically adjust the final clock value for cyclic animation
  7222. regardless of how many total frames. The default value for this
  7223. setting is off.
  7224.  
  7225.  
  7226. 3.2.1.5   Field Rendering
  7227. Field_Render=boo Turn field rendering on/off
  7228. l
  7229. Odd_Field=bool   Set odd field flag
  7230. +UF              Turn field rendering on
  7231. -UF              Turn field rendering off
  7232. +UO              Set odd field flag on
  7233. -UO              Set odd field flag off
  7234. Field rendering is sometimes used for animations when the
  7235. animation is being output for television. TVs only display
  7236. alternate scan lines on each vertical refresh. When each frame is
  7237. being displayed the fields are interlaced to give the impression
  7238. of a higher resolution image. The even scan lines make up the
  7239. even field, and are drawn first (i.e. scan lines 0, 2, 4, etc.),
  7240. followed by the odd field, made up of the odd numbered scan lines
  7241. are drawn afterwards. If objects in an animation are moving
  7242. quickly, their position can change noticeably from one field to
  7243. the next. As a result, it may be desirable in these cases to have
  7244. POV-Ray render alternate fields at the actual field rate (which
  7245. is twice the frame rate), rather than rendering full frames at
  7246. the normal frame rate. This would save a great deal of time
  7247. compared to rendering the entire animation at twice the frame
  7248. rate, and then only using half of each frame.
  7249.  
  7250. By default, field rendering is not used. Setting Field_Render=on
  7251. or using +UF will cause alternate frames in an animation to be
  7252. only the even or odd fields of an animation. By default, the
  7253. first frame is the even field, followed by the odd field. You can
  7254. have POV-Ray render the odd field first by specifying
  7255. Odd_Field=on, or by using the +UO switch.
  7256.  
  7257.  
  7258. 3.2.2     Output Options
  7259.  
  7260. 3.2.2.1   General Output Options
  7261.  
  7262. 3.2.2.1.1 Height and Width of Output
  7263. Height=n       Sets screen height to n
  7264.                pixels
  7265. Width=n        Sets screen width to n
  7266.                pixels
  7267. +Hn            Same as Height=n (when n >
  7268.                8)
  7269. +Wn            Same as Width=n
  7270. These switches set the height and width of the image in pixels.
  7271. This specifies the image size for file output. The preview
  7272. display, if on, will generally attempt to pick a video mode to
  7273. accommodate this size but the display settings do not in any way
  7274. affect the resulting file output.
  7275.  
  7276.  
  7277. 3.2.2.1.2 Partial Output Options
  7278.  
  7279. Start_Column=n     Set first column to n pixels
  7280. Start_Column=0.n   Set first column to n
  7281.                  percent of width
  7282. +SCn or +SC0.n     Same as Start_Column
  7283. Start_Row=n        Set first row to n pixels
  7284. Start_Row=0.n      Set first row to n percent
  7285.                  of height
  7286. +SRn or +Sn        Same as Start_Row=n
  7287. +SR0.n or +S0.n    Same as Start_Row=0.n
  7288. End_Column=n       Set last column to n pixels
  7289. End_Column=0.n     Set last column to n percent
  7290.                  of width
  7291. +ECn or +EC0.n     Same as End_Column
  7292. End_Row=n          Set last row to n pixels
  7293. End_Row=0.n        Set last row to n percent of
  7294.                  height
  7295. +ERn or +En        Same as End_Row=n
  7296. +ER0.n or +E0.n    Same as End_Row=0.n
  7297. When doing test rendering it is often convenient to define a
  7298. small, rectangular sub-section of the whole screen so you can
  7299. quickly check out one area of the image. The Start_Row, End_Row,
  7300. Start_Column and End_Column options allow you to define the
  7301. subset area to be rendered. The default values are the full size
  7302. of the image from (1,1) which is the upper left to (w,h) on the
  7303. lower right where w and h are the Width=n and Height=n values you
  7304. have set.
  7305.  
  7306. Note if the number specified is greater than 1 then it is
  7307. interpreted as an absolute row or column number in pixels. If it
  7308. is a decimal value between 0.0 and 1.0 then it is interpreted as
  7309. a percent of the total width or height of the image. For example:
  7310. Start_Row=0.75 and Start_Column=0.75 starts on a row 75% down
  7311. from the top at a column 75% from the left. Thus it renders only
  7312. the lower-right 25% of the image regardless of the specified
  7313. width and height.
  7314.  
  7315. The +SR, +ER, +SC and +EC switches work in the same way as the
  7316. corresponding INI-style settings for both absolute settings or
  7317. percentages. Early versions of POV-Ray allowed only start and end
  7318. rows to be specified with +Sn and +En so they are still supported
  7319. in addition to +SR and +ER.
  7320.  
  7321.  
  7322. 3.2.2.1.3 Interrupting Options
  7323. Test_Abort=bool  Turn test for user abort
  7324.                  on/off
  7325. +X               Turn test abort on
  7326. -X               Turn test abort off
  7327. Test_Abort_Count Set to test for abort every
  7328. =n               n pixels
  7329. +Xn              Set to test for abort every
  7330.                  n pixels on
  7331. -Xn              Set to test for abort off
  7332.                  (in future test every n
  7333.                  pixels)
  7334. On some operating systems once you start a rendering you must let
  7335. it finish. The Test_Abort=on option or +X switch causes POV-Ray
  7336. to test the keyboard for keypress. If you have pressed a key, it
  7337. will generate a controlled user abort. Files will be flushed and
  7338. closed but only data through the last full row of pixels is
  7339. saved. POV-Ray exits with an error code 2 (normally POV-Ray
  7340. returns 0 for a successful run or 1 for a fatal error).
  7341.  
  7342. When this option is on, the keyboard is polled on every line
  7343. while parsing the scene file and on every pixel while rendering.
  7344. Because polling the keyboard can slow down a rendering, the
  7345. Test_Abort_Count=n option or +Xn switch causes the test to be
  7346. performed only every n pixels rendered or scene lines parsed.
  7347.  
  7348.  
  7349. 3.2.2.1.4 Resuming Options
  7350. Continue_Trace=b Sets continued trace on/off
  7351. ool
  7352. +C               Sets continued trace on
  7353. -C               Sets continued trace off
  7354. Create_Ini=file  Generate an INI file to file
  7355. Create_Ini=true  Generate file.ini where file
  7356.                  is scene name.
  7357. Create_Ini=false Turn off generation of
  7358.                  previously set file.ini
  7359. +GIfile          Same as Create_Ini=file
  7360. If you abort a render while it's in progress or if you used the
  7361. End_Row option to end the render prematurely, you can use
  7362. Continue_Trace=on or +C option to continue the render later at
  7363. the point where you left off. This option reads in the previously
  7364. generated output file, displays the partial image rendered so
  7365. far, then proceeds with the ray-tracing. This option cannot be
  7366. used if file output is disabled with Output_to_file=off or -F.
  7367.  
  7368. The Continue_Trace option may not work if the Start_Row option
  7369. has been set to anything but the top of the file, depending on
  7370. the output format being used.
  7371.  
  7372. POV-Ray tries to figure out where to resume an interrupted trace
  7373. by reading any previously generated data in the specified output
  7374. file. All file formats contain the image size, so this will
  7375. override any image size settings specified. Some file formats
  7376. (namely TGA and PNG) also store information about where the file
  7377. started (i. e. +SCn and +SRn options), alpha output +UA, and bit-
  7378. depth +FNn, which will override these settings. It is up to the
  7379. user to make sure that all other options are set the same as the
  7380. original render.
  7381.  
  7382. The Create_Ini option or +GI switch provides an easy way to
  7383. create an INI file with all of the rendering options, so you can
  7384. re-run files with the same options, or ensure you have all the
  7385. same options when resuming. This option creates an INI file with
  7386. every option set at the value used for that rendering. This
  7387. includes default values which you have not specified. For example
  7388. if you run POV-Ray with...
  7389.  
  7390.  POVRAY +Isimple.pov MYOPTS +GIrerun.ini MOREOPTS
  7391. POV-Ray will create a file called rerun.ini with all of the
  7392. options used to generate this scene. The file is not written
  7393. until all options have been processed. This means that in the
  7394. above example, the file will include options from both myopts.ini
  7395. and moreopts.ini despite the fact that the +GI switch is
  7396. specified between them. You may now re-run the scene with...
  7397.  
  7398.  POVRAY RERUN
  7399. or resume an interrupted trace with
  7400.  
  7401.  POVRAY RERUN +C
  7402. If you add other switches with the rerun.ini reference, they will
  7403. be included in future re-runs because the file is re-written
  7404. every time you use it.
  7405.  
  7406. The Create_Ini option is also useful for documenting how a scene
  7407. was rendered. If you render waycool.pov with Create_Ini=on then
  7408. it will create a file waycool.ini that you could distribute along
  7409. with your scene file so other users can exactly re-create your
  7410. image.
  7411.  
  7412.  
  7413. 3.2.2.2   Display Output Options
  7414.  
  7415. 3.2.2.2.1 Display Hardware Settings
  7416. Display=bool     Turns graphic display on/off
  7417. +D               Turns graphic display on
  7418. -D               Turns graphic display off
  7419. Video_Mode=x     Set video mode to x; does
  7420.                  not affect on/off
  7421. +Dx              Set display on; Set mode to
  7422.                  x
  7423. -Dx              Set display off; but for
  7424.                  future use mode x
  7425. Palette=y        Set display palette to y;
  7426.                  does not affect on/off
  7427. +Dxy             Set display on; Set mode x;
  7428.                  Set palette y
  7429. -Dxy             Set display off; use mode x,
  7430.                  palette y in future
  7431. Display_Gamma=n. Sets the display gamma to
  7432. n                n.n
  7433. The Display=on or +D switch will turn on the graphics display of
  7434. the image while it is being rendered. Even on some non-graphics
  7435. systems, POV-Ray may display an 80 by 24 character  "ASCII-Art"
  7436. version of your image. Where available, the display may be full,
  7437. 24-bit true color. Setting Display=off or using the -D switch
  7438. will turn off the graphics display which is the default.
  7439.  
  7440. The Video_Mode=x option sets the display mode or hardware type
  7441. chosen where x is a single digit or letter that is machine
  7442. dependent. Generally Video_Mode=0 means the default or an auto-
  7443. detected setting should be used. When using switches, this
  7444. character immediately follows the switch. For example the +D0
  7445. switch will turn on the graphics display in the default mode.
  7446.  
  7447. The Palette=y option selects the palette to be used. Typically
  7448. the single character parameter y is a digit which selects one of
  7449. several fixed palettes or a letter such G for gray scale, H for
  7450. 15-bit or 16-bit high color or T for 24-bit true color. When
  7451. using switches, this character is the 2nd character after the
  7452. switch. For example the +D0T switch will turn on the graphics
  7453. display in the default mode with a true color palette.
  7454.  
  7455. The Display_Gamma=n.n setting is new with POV-Ray 3.0, and is not
  7456. available as a command-line switch. The Display_Gamma setting
  7457. overcomes the problem of images (whether ray-traced or not)
  7458. having different brightness when being displayed on different
  7459. monitors, different video cards, and under different operating
  7460. systems. Note that the Display_Gamma is a setting based on your
  7461. computer's display hardware, and should be set correctly once and
  7462. not changed. The Display_Gamma INI setting works in conjunction
  7463. with the new assumed_gamma global setting to ensure that POV
  7464. scenes and the images they create look the same on all systems.
  7465. See section "Assumed_Gamma" which describes the assumed_gamma
  7466. global setting and describes gamma more thoroughly.
  7467.  
  7468. While the Display_Gamma can be different for each system, there
  7469. are a few general rules that can be used for setting
  7470. Display_Gamma if you don't know it exactly. If the Display_Gamma
  7471. keyword does not appear in the INI file, POV-Ray assumes that the
  7472. display gamma is 2.2. This is because most PC monitors have a
  7473. gamma value in the range 1.6 to 2.6 (newer models seem to have a
  7474. lower gamma value). Mac has the ability to do gamma correction
  7475. inside the system software (based on a user setting in the gamma
  7476. control panel). If the gamma control panel is turned off, or is
  7477. not available, the default Macintosh system gamma is 1.8. Some
  7478. high-end PC graphics cards can do hardware gamma correction and
  7479. should use the current Display_Gamma setting, usually 1.0. A
  7480. gamma test image is also available to help users to set their
  7481. Display_Gamma accurately.
  7482.  
  7483. For scene files that do not contain an assumed_gamma global
  7484. setting the INI file option Display_Gamma will not have any
  7485. affect on the preview output of POV-Ray or for most output file
  7486. formats. However, the Display_Gamma value is used when creating
  7487. PNG format output files, and also when rendering the POV-Ray
  7488. example files (because they have an assumed_gamma), so it should
  7489. still be correctly set for your system to ensure proper results.
  7490.  
  7491.  
  7492. 3.2.2.2.2 Display Related Settings
  7493. Pause_When_Done=bo  Sets pause when done
  7494. ol                  on/off
  7495. +P                  Sets pause when done on
  7496. -P                  Sets pause when done off
  7497. Verbose=bool        Set verbose messages
  7498.                     on/off
  7499. +V                  Set verbose messages on
  7500. -V                  Set verbose messages off
  7501. Draw_Vistas=bool    Turn draw vistas on/off
  7502. +UD                 Turn draw vistas on
  7503. -UD                 Turn draw vistas off
  7504. On some systems, when the image is complete, the graphics display
  7505. is cleared and POV-Ray switches back into text mode to print the
  7506. final statistics and to exit. Normally when the graphics display
  7507. is on, you want to look at the image awhile before continuing.
  7508. Using Pause_When_Done=on or +P causes POV-Ray to pause in
  7509. graphics mode until you press a key to continue. The default is
  7510. not to pause (-P).
  7511.  
  7512. When the graphics display is not used, it is often desirable to
  7513. monitor progress of the rendering. Using Verbose=on or +V turns
  7514. on verbose reporting of your rendering progress. This reports the
  7515. number of the line currently being rendered, the elapsed time for
  7516. the current frame and other information. On some systems, this
  7517. textual information can conflict with the graphics display. You
  7518. may need to turn this off when the display is on. The default
  7519. setting is off (-V).
  7520.  
  7521. The option Draw_Vistas=on or +UD was originally a debugging help
  7522. for POV-Ray's vista buffer feature but it was such fun we decided
  7523. to keep it. Vista buffering is a spatial sub-division method that
  7524. projects the 2-D extents of bounding boxes onto the viewing
  7525. window. POV-Ray tests the 2-D x, y pixel location against these
  7526. rectangular areas to determine quickly which objects, if any, the
  7527. viewing ray will hit. This option shows you the 2-D rectangles
  7528. used. The default setting is off (-UD) because the drawing of the
  7529. rectangles can take considerable time on complex scenes and it
  7530. serves no critical purpose. See section "Automatic Bounding
  7531. Control" for more details.
  7532.  
  7533.  
  7534. 3.2.2.2.3 Mosaic Preview
  7535. Preview_Start_Size=n  Set mosaic preview start
  7536.                     size to n
  7537. +SPn                Same as Preview_Start_Size=n
  7538. Preview_End_Size=n  Set mosaic preview end size
  7539.                     to n
  7540. +EPn                Same as Preview_End_Size=n
  7541. Typically, while you are developing a scene, you will do many low
  7542. resolution test renders to see if objects are placed properly.
  7543. Often this low resolution version doesn't give you sufficient
  7544. detail and you have to render the scene again at a higher
  7545. resolution. A feature called "mosaic preview" solves this problem
  7546. by automatically rendering your image in several passes.
  7547.  
  7548. The early passes paint a rough overview of the entire image using
  7549. large blocks of pixels that look like mosaic tiles. The image is
  7550. then refined using higher resolutions on subsequent passes. This
  7551. display method very quickly displays the entire image at a low
  7552. resolution, letting you look for any major problems with the
  7553. scene. As it refines the image, you can concentrate on more
  7554. details, like shadows and textures. You don't have to wait for a
  7555. full resolution render to find problems, since you can interrupt
  7556. the rendering early and fix the scene, or if things look good,
  7557. you can let it continue and render the scene at high quality and
  7558. resolution.
  7559.  
  7560. To use this feature you should first select a Width and Height
  7561. value that is the highest resolution you will need. Mosaic
  7562. preview is enabled by specifying how big the mosaic blocks will
  7563. be on the first pass using Preview_Start_Size=n or +SPn. The
  7564. value n should be a number greater than zero that is a power of
  7565. two (1, 2, 4, 8, 16, 32, etc.) If it is not a power of two, the
  7566. nearest power of two less than n is substituted. This sets the
  7567. size of the squares, measured in pixels. A value of 16 will draw
  7568. every 16th pixel as a 16*16 pixel square on the first pass.
  7569. Subsequent passes will use half the previous value (such as 8*8,
  7570. 4*4 and so on.)
  7571.  
  7572. The process continues until it reaches 1*1 pixels or until it
  7573. reaches the size you set with Preview_End_Size=n or +EPn. Again
  7574. the value n should be a number greater than zero that is a power
  7575. of two and less than or equal to Preview_Start_Size. If it is not
  7576. a power of two, the nearest power of two less than n is
  7577. substituted. The default ending value is 1. If you set
  7578. Preview_End_Size to a value greater than 1 the mosaic passes will
  7579. end before reaching 1*1, but POV-Ray will always finish with a
  7580. 1*1. For example, if you want a single 8*8 mosaic pass before
  7581. rendering the final image, set Preview_Start_Size=8 and
  7582. Preview_End_Size=8.
  7583.  
  7584. No file output is performed until the final 1*1 pass is reached.
  7585. Although the preliminary passes render only as many pixels as
  7586. needed, the 1*1 pass re-renders every pixel so that anti-aliasing
  7587. and file output streams work properly. This makes the scene take
  7588. up to 25% longer than the regular 1*1 pass to render, so it is
  7589. suggested that mosaic preview not be used for final rendering.
  7590. Also, the lack of file output until the final pass means that
  7591. renderings which are interrupted before the 1*1 pass can not be
  7592. resumed without starting over from the beginning.
  7593.  
  7594. Future versions of POV-Ray will include some system of temporary
  7595. files or buffers which will eliminate these inefficiencies and
  7596. limitations. Mosaic preview is still a very useful feature for
  7597. test renderings.
  7598.  
  7599.  
  7600. 3.2.2.3   File Output Options
  7601. Output_to_File=b Sets file output on/off
  7602. ool
  7603. +F               Sets file output on (use
  7604.                  default type)
  7605. -F               Sets file output off
  7606. By default, POV-Ray writes an image file to disk. When you are
  7607. developing a scene and doing test renders, the graphic preview
  7608. may be sufficient. To save time and disk activity you may turn
  7609. file output off with Output_to_File=off or -F.
  7610.  
  7611.  
  7612. 3.2.2.3.1 Output File Type
  7613. Output_File_Type Sets file output format to x
  7614. =x
  7615. +Fxn             Sets file output on; sets
  7616.                  format x, depth n
  7617. -Fxn             Sets file output off; but in
  7618.                  future use format x, depth n
  7619. Output_Alpha=boo Sets alpha output on/off
  7620. l
  7621. +UA              Sets alpha output on
  7622. -UA              Sets alpha output off
  7623. Bits_Per_Color=n Sets file output bits/color to
  7624.                  n
  7625. The default type of image file depends on which platform you are
  7626. using. MS-DOS and most others default to 24-bit uncompressed
  7627. Targa. See your platform-specific documentation to see what your
  7628. default file type is. You may select one of several different
  7629. file types using Output_File_Type=x or +Fx where x is one of the
  7630. following...
  7631. +FC Compressed Targa-24 format (RLE,
  7632.     run length encoded)
  7633. +FN New PNG (portable network
  7634.     graphics) format
  7635. +FP Unix PPM format
  7636. +FS System-specific such as Mac Pict
  7637.     or Windows BMP
  7638. +FT Uncompressed Targa-24 format
  7639. Note that the obsolete +FD dump format and +FR raw format have
  7640. been dropped from POV-Ray 3.0 because they were rarely used and
  7641. no longer necessary. PPM, PNG, and system specific formats have
  7642. been added. PPM format images are uncompressed, and have a simple
  7643. text header, which makes it a widely portable image format. PNG
  7644. is a new image format designed not only to replace GIF, but to
  7645. improve on its shortcomings. PNG offers the highest compression
  7646. available without loss for high quality applications, such as ray-
  7647. tracing. The system specific format depends on the platform used
  7648. and is covered in the appropriate system specific documentation.
  7649.  
  7650. Most of these formats output 24 bits per pixel with 8 bits for
  7651. each of red, green and blue data. PNG allows you to optionally
  7652. specify the output bit depth from 5 to 16 bits for each of the
  7653. red, green, and blue colors, giving from 15 to 48 bits of color
  7654. information per pixel. The default output depth for all formats
  7655. is 8 bits/color (16 million possible colors), but this may be
  7656. changed for PNG format files by setting Bits_Per_Color=n or by
  7657. specifying +FNn, where n is the desired bit depth.
  7658.  
  7659. Specifying a smaller color depth like 5 bits/color (32768 colors)
  7660. may be enough for people with 8- or 16-bit (256 or 65536 color)
  7661. displays, and will improve compression of the PNG file. Higher
  7662. bit depths like 10 or 12 may be useful for video or publishing
  7663. applications, and 16 bits/color is good for grayscale height
  7664. field output (See section "Height Field" for details on height
  7665. fields).
  7666.  
  7667. Targa format also allows 8 bits of alpha transparency data to be
  7668. output, while PNG format allows 5 to 16 bits of alpha
  7669. transparency data, depending on the color bit depth as specified
  7670. above. You may turn this option on with Output_Alpha=on or +UA.
  7671. The default is off or -UA. See section "Using the Alpha Channel"
  7672. for further details on transparency.
  7673.  
  7674. In addition to support for variable bit-depths, alpha channel,
  7675. and grayscale formats, PNG files also store the Display_Gamma
  7676. value so the image displays properly on all systems (see section
  7677. "Display Hardware Settings"). The hf_gray_16 global setting, as
  7678. described in section "HF_Gray_16" will also affect the type of
  7679. data written to the output file.
  7680.  
  7681.  
  7682. 3.2.2.3.2 Output File Name
  7683.  
  7684. Output_File_Name=file    Sets output file to
  7685.                          file
  7686. +Ofile                   Same as
  7687.                          Output_File_Name=file
  7688. The default output filename is created from the scene name and
  7689. need not be specified. The scene name is the input name with all
  7690. drive, path, and extension information stripped. For example if
  7691. the input file name is c:\povray3\mystuff\myfile.pov the scene
  7692. name is myfile. The proper extension is appended to the scene
  7693. name based on the file type. For example myfile.tga or myfile.png
  7694. might be used.
  7695.  
  7696. You may override the default output name using
  7697. Output_File_Name=file or +Ofile. For example:
  7698.  
  7699.  Input_File_Name=myinput.pov
  7700.  Output_File_Name=myoutput.tga
  7701. If an output file name of "-" is specified (a single minus sign),
  7702. then the image will be written to standard output, usually the
  7703. screen. The output can then be piped into another program or to a
  7704. GUI if desired.
  7705.  
  7706. If the file specified is actually a path or directory or folder
  7707. name and not a file name, then the default output name is used
  7708. but it is written to the specified directory.  For example:
  7709.  
  7710.  Input_File_Name=myscene.pov
  7711.  Output_File_Name=c:\povray3\myimages\
  7712. This will create c:\povray3\myimages\myscene.tga as the output
  7713. file.
  7714.  
  7715.  
  7716. 3.2.2.3.3 Output File Buffer
  7717. Buffer_Output=b  Turn output buffering on/off
  7718. ool
  7719. +B               Turn output buffering on
  7720. -B               Turn output buffering off
  7721. Buffer_Size=n    Set output buffer size to n
  7722.                  kilobytes.  If n is zero, no
  7723.                  buffering. If n < system
  7724.                  default, the system default
  7725.                  is used.
  7726. +Bn              Turn buffer on, set size n
  7727. -Bn              Turn buffer off, but for
  7728.                  future set size n
  7729. The Buffer_Output and Buffer_Size options and the +B switch
  7730. allows you to assign large buffers to the output file. This
  7731. reduces the amount of time spent writing to the disk. If this
  7732. parameter is not specified, then as each row of pixels is
  7733. finished, the line is written to the file and the file is
  7734. flushed. On most systems, this operation ensures that the file is
  7735. written to the disk so that in the event of a system crash or
  7736. other catastrophic event, at least a part of the picture has been
  7737. stored properly and retrievable on disk. The default is not to
  7738. use any buffer.
  7739.  
  7740.  
  7741. 3.2.2.4   CPU Utilization Histogram
  7742. The CPU utilization histogram is a way of finding out where POV-
  7743. Ray is spending its rendering time, as well as an interesting way
  7744. of generating heightfields. The histogram splits up the screen
  7745. into a rectangular grid of blocks. As POV-Ray renders the image,
  7746. it calculates the amount of time it spends rendering each pixel
  7747. and then adds this time to the total rendering time for each grid
  7748. block. When the rendering is complete, the histogram is a file
  7749. which represents how much time was spent computing the pixels in
  7750. each grid block.
  7751.  
  7752. Not all versions of POV-Ray allow the creation of histograms. The
  7753. histogram output is dependent on the file type and the system
  7754. that POV-Ray is being run on.
  7755.  
  7756.  
  7757. 3.2.2.4.1 File Type
  7758. Histogram_Type=y Set histogram type to y
  7759.                  (Turn off if type is 'X')
  7760. +HTy             Same as Histogram_Type=y
  7761. The histogram output file type is nearly the same as that used
  7762. for the image output file types in "Output File Type". The
  7763. available histogram file types are as follows.
  7764. +HTC      Comma separated values (CSV)
  7765.           often used in spreadsheets
  7766. +HTN      New PNG (portable network
  7767.           graphics) format grayscale
  7768. +HTP      Unix PPM format
  7769. +HTS      System-specific such as Mac Pict
  7770.           or Windows BMP
  7771. +HTT      Uncompressed Targa-24 format
  7772.           (TGA)
  7773. +HTX      No histogram file output is
  7774.           generated
  7775. Note that +HTC does not generate a compressed Targa-24 format
  7776. output file but rather a text file with a comma-separated list of
  7777. the time spent in each grid block, in left-to-right and top-to
  7778. bottom order. The units of time output to the CSV file are system
  7779. dependent. See the system specific documentation for further
  7780. details on the time units in CSV files.
  7781.  
  7782. The Targa and PPM format files are in the POV heightfield format
  7783. (see "Height Field"), so the histogram information is stored in
  7784. both the red and green parts of the image, which makes it
  7785. unsuitable for viewing. When used as a height field, lower values
  7786. indicate less time spent calculating the pixels in that block,
  7787. while higher indicate more time spent in that block.
  7788.  
  7789. PNG format images are stored as grayscale images and are useful
  7790. for both viewing the histogram data as well as for use as a
  7791. heightfield. In PNG files, the darker (lower) areas indicate less
  7792. time spent in that grid block, while the brighter (higher) areas
  7793. indicate more time spent in that grid block.
  7794.  
  7795.  
  7796. 3.2.2.4.2 File Name
  7797. Histogram_Name=f Set histogram name to file
  7798. ile
  7799. +HNfile          Same as Histogram_Name=file
  7800. The histogram file name is the name of the file in which to write
  7801. the histogram data. If the file name is not specified it will
  7802. default to histgram.ext, where ext is based on the file type
  7803. specified previously. Note that if the histogram name is
  7804. specified the file name extension should match the file type.
  7805.  
  7806.  
  7807. 3.2.2.4.3 Grid Size
  7808. Histogram_Grid_Size=n  Set histogram grid to nn by
  7809. n.mm                   mm
  7810. +HSnn.mm               Same as
  7811.                        Histogram_Grid_Size=nn.mm
  7812. The histogram grid size gives the number of times the image is
  7813. split up in both the horizontal and vertical directions. For
  7814. example
  7815.  
  7816.  povray +Isample +W640 +H480 +HTN +HS160.120 +HNhistogrm.png
  7817. will split the image into 160*120 grid blocks, each of size 4*4
  7818. pixels, and output a PNG file, suitable for viewing or for use as
  7819. a heightfield. Smaller numbers for the grid size mean more pixels
  7820. are put into the same grid block. With CSV output, the number of
  7821. values output is the same as the number of grid blocks specified.
  7822. For the other formats the image size is identical to the rendered
  7823. image rather than the specified grid size, to allow easy
  7824. comparison between the histogram and the rendered image. If the
  7825. histogram grid size is not specified, it will default to the same
  7826. size as the image, so there will be one grid block per pixel.
  7827.  
  7828. Note that on systems that do task-switching or multi-tasking the
  7829. histogram may not exactly represent the amount of time POV-Ray
  7830. spent in a given grid block since the histogram is based on real
  7831. time rather than CPU time. As a result, time may be spent for
  7832. operating system overhead or on other tasks running at the same
  7833. time. This will cause the histogram to have speckling, noise or
  7834. large spikes. This can be reduced by decreasing the grid size so
  7835. that more pixels are averaged into a given grid block.
  7836.  
  7837.  
  7838. 3.2.3     Scene Parsing Options
  7839. POV-Ray reads in your scene file and processes it to create an
  7840. internal model of your scene. The process is called parsing. As
  7841. your file is parsed other files may be read along the way. This
  7842. section covers options concerning what to parse, where to find it
  7843. and what version specific assumptions it should make while
  7844. parsing it.
  7845.  
  7846.  
  7847. 3.2.3.1   Input File Name
  7848. Input_File_Name=fi  Sets input file name to
  7849. le                  file
  7850. +Ifile              Same as
  7851.                     Input_File_Name=file
  7852. You will probably always set this option but if you do not the
  7853. default input filename is object.pov. If you do not have an
  7854. extension then .pov is assumed. On case-sensitive operating
  7855. systems both .pov and .POV are tried. A full path specification
  7856. may be used (on MS-DOS systems +Ic:\povray3\mystuff\myfile.pov is
  7857. allowed for example). In addition to specifying the input file
  7858. name this also establishes the scene name.
  7859.  
  7860. The scene name is the input name with drive, path and extension
  7861. stripped. In the above example the scene name is myfile. This
  7862. name is used to create a default output file name and it is
  7863. referenced other places.
  7864.  
  7865. If you use "-" as the input file name the input will be read from
  7866. standard input. Thus you can pipe a scene created by a program to
  7867. POV-Ray and render it without having a scene file.
  7868.  
  7869. Under MS-DOS you can try this feature by typing.
  7870.  
  7871.  type ANYSCENE.POV | povray +I-
  7872.  
  7873. 3.2.3.2   Library Paths
  7874. Library_Path=pat Add path to list of
  7875. h                library paths
  7876. +Lpath           Same as Library_Path=path
  7877. POV-Ray looks for files in the current directory. If it does not
  7878. find a file it needs it looks in various other library
  7879. directories which you specify. POV-Ray does not search your
  7880. operating system path. It only searches the current directory and
  7881. directories which you specify with this option. For example the
  7882. standard include files are usually kept in one special directory.
  7883. You tell POV-Ray to look there with...
  7884.  
  7885.  Library_Path=c:\povray3\include
  7886. You must not specify any final path separators ("\" or "/") at
  7887. the end.
  7888.  
  7889. Multiple uses of this option switch do not override previous
  7890. settings. Up to twenty unique paths may be specified. If you
  7891. specify the exact same path twice it is only counts once. The
  7892. current directory will be searched first followed by the
  7893. indicated library directories in the order in which you specified
  7894. them.
  7895.  
  7896.  
  7897. 3.2.3.3   Language Version
  7898. Version=n.n    Set initial language
  7899.                compatibility to version n.n
  7900. +MVn.n         Same as Version=n.n
  7901. As POV-Ray as evolved from version 1.0 through 3.1 we have made
  7902. every effort to maintain some amount of backwards compatibility
  7903. with earlier versions.  Some old or obsolete features can be
  7904. handled directly without any special consideration by the user.
  7905. Some old or obsolete features can no longer be handled at all.
  7906. However some old features can still be used if you warn POV-Ray
  7907. that this is an older scene.  In the POV-Ray scene language you
  7908. can use the #version directive to switch version compatibility to
  7909. different setting.  See section "The #version Directive" for more
  7910. details about the language version directive.  Additionally you
  7911. may use the Version=n.n option or the +MVn.n switch to establish
  7912. the initial setting.  For example one feature introduced in 2.0
  7913. that was incompatible with any 1.0 scene files is the parsing of
  7914. float expressions. Setting Version=1.0 or using +MV1.0 turns off
  7915. expression parsing as well as many warning messages so that
  7916. nearly all 1.0 files will still work. Naturally the default
  7917. setting for this option is Version=3.1.
  7918.  
  7919. NOTE: Some obsolete or re-designed features are totally
  7920. unavailable in POV-Ray 3.1 REGARDLES OF THE VERSION SETTING.
  7921. Details on these features are noted throughout this
  7922. documentation.
  7923.  
  7924.  
  7925. 3.2.4     Shell-out to Operating System
  7926. Pre_Scene_Command=  Set command before entire
  7927. s                   scene
  7928. Pre_Frame_Command=  Set command before each
  7929. s                   frame
  7930. Post_Scene_Command  Set command after entire
  7931. =s                  scene
  7932. Post_Frame_Command  Set command after each frame
  7933. =s
  7934. User_Abort_Command  Set command when user aborts
  7935. =s                  POV-Ray
  7936. Fatal_Error_Comman  Set command when POV-Ray has
  7937. d=s                 fatal error
  7938. Note that no + or - switches are available for these options.
  7939. They cannot be used from the command line. They may only be used
  7940. from INI files.
  7941.  
  7942. POV-Ray offers you the opportunity to shell-out to the operating
  7943. system at several key points to execute another program or batch
  7944. file. Usually this is used to manage files created by the
  7945. internal animation loop however the shell commands are available
  7946. for any scene. The string s is a single line of text which is
  7947. passed to the operating system to execute a program. For example
  7948.  
  7949.  Post_Scene_Command=tga2gif -d -m myfile
  7950. would use the utility tga2gif with the -D and -M parameters to
  7951. convert myfile.tga to myfile.gif after the scene had finished
  7952. rendering.
  7953.  
  7954.  
  7955. 3.2.4.1   String Substitution in Shell Commands
  7956. It could get cumbersome to change the Post_Scene_Command every
  7957. time you changed scene names. POV-Ray can substitute various
  7958. values into a command string for you. For example:
  7959.  
  7960.  Post_Scene_Command=tga2gif -d -m %s
  7961. POV-Ray will substitute the %s with the scene name in the
  7962. command. The scene name is the Input_File_Name or +I setting with
  7963. any drive, directory and extension removed. For example:
  7964.  
  7965.  Input_File_Name=c:\povray3\scenes\waycool.pov
  7966. is stripped down to the scene name waycool which results in...
  7967.  
  7968.  Post_Scene_Command=tga2gif -d -m waycool
  7969. In an animation it may be necessary to have the exact output file
  7970. name with the frame number included. The string %o will
  7971. substitute the output file name. Suppose you want to save your
  7972. output files in a zip archive using the utility program pkzip.
  7973. You could do...
  7974.  
  7975.  Post_Frame_Command=pkzip -m %s %o
  7976. After rendering frame 12 of myscene.pov POV-Ray would shell to
  7977. the operating system with
  7978.  
  7979.  pkzip -m myscene mysce012.tga
  7980. The -M switch in pkzip moves mysce012.tga to myscene.zip and
  7981. removes it from the directory. Note that %o includes frame
  7982. numbers only when in an animation loop. During the
  7983. Pre_Scene_Command and Post_Scene_Command there is no frame number
  7984. so the original, unnumbered Output_File_Name is used. Any
  7985. User_Abort_Command or Fatal_Error_Command not inside the loop
  7986. will similarly give an unnumbered %o substitution.
  7987.  
  7988. Here is the complete list of substitutions available for a
  7989. command string.
  7990. %o   Output file name with extension and
  7991.      embedded frame number if any
  7992. %s   Scene name derived by stripping path
  7993.      and ext from input name
  7994. %n   Frame number of this frame
  7995. %k   Clock value of this frame
  7996. %h   Height of image in pixels
  7997. %w   Width of image in pixels
  7998. %%   A single % sign.
  7999.  
  8000. 3.2.4.2   Shell Command Sequencing
  8001. Here is the sequence of events in an animation loop. Non-animated
  8002. scenes work the exact same way except there is no loop.
  8003.  
  8004. 1)Process all INI file keywords and command line switches just
  8005.   once.
  8006. 2)Open any text output streams and do Create_INI if any.
  8007. 3)Execute Pre_Scene_Command if any.
  8008. 4)Loop through frames (or just do once on non-animation).
  8009.   a)Execute Pre_Frame_Command if any.
  8010.   b)Parse entire scene file, open output file and read settings,
  8011.      turn on display, render the frame, destroy all objects,
  8012.      textures etc., close output file, close display.
  8013.   c)Execute Post_Frame_Command if any.
  8014.   d)Go back to (4a) until all frames are done.
  8015. 5)Execute Post_Scene_Command if any.
  8016. 6)Exit POV-Ray.
  8017. If the user interrupts processing the User_Abort_Command, if any,
  8018. is executed. User aborts can only occur during the parsing and
  8019. rendering parts of step (4b) above.
  8020.  
  8021. If a fatal error occurs that POV-Ray notices the
  8022. Fatal_Error_Command, if any, is executed. Sometimes an unforeseen
  8023. bug or memory error could cause a total crash of the program in
  8024. which case there is no chance to shell out. Fatal errors can
  8025. occur just about anywhere including during the processing of
  8026. switches or INI files. If a fatal error occurs before POV-Ray has
  8027. read the Fatal_Error_Command string then obviously no shell can
  8028. occur.
  8029.  
  8030. Note that the entire scene is re-parsed for every frame. Future
  8031. versions of POV-Ray may allow you to hold over parts of a scene
  8032. from one frame to the next but for now it starts from scratch
  8033. every time. Note also that the Pre_Frame_Command occurs before
  8034. the scene is parsed. You might use this to call some custom scene
  8035. generation utility before each frame. This utility could rewrite
  8036. your .pov or .inc files if needed. Perhaps you will want to
  8037. generate new .gif or .tga files for image maps or height fields
  8038. on each frame.
  8039.  
  8040.  
  8041. 3.2.4.3   Shell Command Return Actions
  8042. Pre_Scene_Return=s  Set pre scene return
  8043.                     actions
  8044. Pre_Frame_Return=s  Set pre frame return
  8045.                     actions
  8046. Post_Scene_Return=  Set post scene return
  8047. s                   actions
  8048. Post_Frame_Return=  Set post frame return
  8049. s                   actions
  8050. User_Abort_Return=  Set user abort return
  8051. s                   actions
  8052. Fatal_Error_Return  Set fatal return actions
  8053. =s
  8054. Note that no + or - switches are available for these options.
  8055. They cannot be used from the command line. They may only be used
  8056. from INI files.
  8057.  
  8058. Most operating systems allow application programs to return an
  8059. error code if something goes wrong. When POV-Ray executes a shell
  8060. command it can make use of this error code returned from the
  8061. shell process and take some appropriate action if the code is
  8062. zero or non-zero. POV-Ray itself returns such codes. It returns 0
  8063. for success, 1 for fatal error and 2 for user abort.
  8064.  
  8065. The actions are designated by a single letter in the different
  8066. ..._Return=s options. The possible actions are:
  8067. I  ignore the code
  8068. S  skip one step
  8069. A  all steps skipped
  8070. Q  quit POV-Ray
  8071.    immediately
  8072. U  generate a user abort
  8073.    in POV-Ray
  8074. F  generate a fatal error
  8075.    in POV-Ray
  8076. For example if your Pre_Frame_Command calls a program which
  8077. generates your height field data and that utility fails then it
  8078. will return a non-zero code. We would probably want POV-Ray to
  8079. abort as well. The option Pre_Frame_Return=F will cause POV-Ray
  8080. to do a fatal abort if the Pre_Frame_Command returns a non-zero
  8081. code.
  8082.  
  8083. Sometimes a non-zero code from the external process is a good
  8084. thing. Suppose you want to test if a frame has already been
  8085. rendered. You could use the S action to skip this frame if the
  8086. file is already rendered. Most utilities report an error if the
  8087. file is not found. For example the command...
  8088.  
  8089.  pkzip -V myscene mysce012.tga
  8090. tells pkzip you want to view the catalog of myscene.zip for the
  8091. file mysce012.tga. If the file isn't in the archive pkzip returns
  8092. a non-zero code.
  8093.  
  8094. However we want to skip if the file is found. Therefore we need
  8095. to reverse the action so it skips on zero and doesn't skip on non-
  8096. zero. To reverse the zero vs. non-zero triggering of an action
  8097. precede it with a "-" sign (note a "!" will also work since it is
  8098. used in many programming languages as a negate operator).
  8099.  
  8100. Pre_Frame_Return=S will skip if the code shows error (non-zero)
  8101. and will proceed normally on no error (zero). Pre_Frame_Return=-S
  8102. will skip if there is no error (zero) and will proceed normally
  8103. if there is an error (non-zero).
  8104.  
  8105. The default for all shells is I which means that the return
  8106. action is ignored no matter what. POV-Ray simply proceeds with
  8107. whatever it was doing before the shell command. The other actions
  8108. depend upon the context. You may want to refer back to the
  8109. animation loop sequence chart in the previous section "Shell
  8110. Command Sequencing". The action for each shell is as follows.
  8111.  
  8112. On return from any User_Abort_Command if there is an action
  8113. triggered...
  8114.  
  8115. and you have     ... then POV-Ray will..
  8116. specified...
  8117. F                Then turn this user abort
  8118.                  into a fatal error.
  8119.                  Do the
  8120.                  Fatal_Error_Command, if
  8121.                  any.
  8122.                  Exit POV-Ray with error
  8123.                  code 1.
  8124. S, A, Q, or U    Then proceed with the user
  8125.                  abort.
  8126.                  Exit POV-Ray with error
  8127.                  code 2.
  8128. On return from any Fatal_Error_Command then POV-Ray will proceed
  8129. with the fatal error no matter what. It will exit POV-Ray with
  8130. error code 1.
  8131.  
  8132. On return from any Pre_Scene_Command, Pre_Frame_Command,
  8133. Post_Frame_Command or Post_Scene_Commands if there is an action
  8134. triggered...
  8135. ...and you have  ... then POV-Ray will...
  8136. specified...
  8137. F                ...turn this user abort into
  8138.                     a fatal error. Do the
  8139.                     Fatal_Error_Command, if
  8140.                     any. Exit POV-Ray with
  8141.                     error code 1.
  8142. U                ...generate a user abort. Do
  8143.                     the User_Abort_Command, if
  8144.                     any. Exit POV-Ray with an
  8145.                     error code 2.
  8146. Q                ..quit POV-Ray immediately.
  8147.                     Acts as though POV-Ray
  8148.                     never really ran. Do no
  8149.                     further shells, (not even
  8150.                     a Post_Scene_Command) and
  8151.                     exit POV-Ray with an error
  8152.                     code 0.
  8153. On return from a Pre_Scene_Command if there is an action
  8154. triggered...
  8155. ...and you have  ... then POV-Ray will...
  8156. specified...
  8157. S                ...skip rendering all
  8158.                     frames. Acts as though the
  8159.                     scene completed all frames
  8160.                     normally. Do not do any
  8161.                     Pre_Frame_Command or
  8162.                     Post_Frame_Commands. Do
  8163.                     the Post_Scene_Command, if
  8164.                     any. Exit POV-Ray with
  8165.                     error code 0. On the
  8166.                     earlier chart this means
  8167.                     skip step #4.
  8168. A                ...skip all scene activity.
  8169.                     Works exactly like Q quit.
  8170.                     On the earlier chart this
  8171.                     means skip to step #6.
  8172.                     Acts as though POV-Ray
  8173.                     never really ran. Do no
  8174.                     further shells, (not even
  8175.                     a Post_Scene_Command) and
  8176.                     exit POV-Ray with an error
  8177.                     code 0.
  8178. On return from a Pre_Frame_Command if there is an action
  8179. triggered...
  8180. ...and you have  ... then POV-Ray will...
  8181. specified...
  8182. S                ...skip only this frame.
  8183.                     Acts as though this frame
  8184.                     never existed. Do not do
  8185.                     the Post_Frame_Command.
  8186.                     Proceed with the next
  8187.                     frame. On the earlier
  8188.                     chart this means skip
  8189.                     steps (4b) and (4c) but
  8190.                     loop back as needed in
  8191.                     (4d).
  8192. A                ...skip rendering this frame
  8193.                     and all remaining frames.
  8194.                     Acts as though the scene
  8195.                     completed all frames
  8196.                     normally. Do not do any
  8197.                     further
  8198.                     Post_Frame_Commands. Do
  8199.                     the Post_Scene_Command, if
  8200.                     any. Exit POV-Ray with
  8201.                     error code 0. On the
  8202.                     earlier chart this means
  8203.                     skip the rest of step (4)
  8204.                     and proceed at step (5).
  8205. On return from a Post_Frame_Command if there is an action
  8206. triggered...
  8207. ...and you have  ... then POV-Ray will...
  8208. specified...
  8209. S or A           ...skip all remaining
  8210.                     frames. Acts as though the
  8211.                     scene completed all frames
  8212.                     normally. Do not do any
  8213.                     further
  8214.                     Post_Frame_Commands. Do
  8215.                     the Post_Scene_Command, if
  8216.                     any. Exit POV-Ray with
  8217.                     error code 0. On the
  8218.                     earlier chart this means
  8219.                     skip the rest of step (4)
  8220.                     and proceed at step (5).
  8221. On return from any Post_Scene_Command if there is an action
  8222. triggered and you have specified S or A then no special action
  8223. occurs.  This is the same as I for this shell command.
  8224.  
  8225.  
  8226. 3.2.5     Text Output
  8227. Text output is an important way that POV-Ray keeps you informed
  8228. about what it is going to do, what it is doing and what it did.
  8229. New to POV-Ray 3.0, the program splits its text messages into 7
  8230. separate streams. Some versions of POV-Ray color-codes the
  8231. various types of text. Some versions allow you to scroll back
  8232. several pages of messages. All versions allow you to turn some of
  8233. these text streams off/on or to direct a copy of the text output
  8234. to one or several files. This section details the options which
  8235. give you control over text output.
  8236.  
  8237.  
  8238. 3.2.5.1   Text Streams
  8239. There are seven distinct text streams that POV-Ray uses for
  8240. output. On some versions each stream is designated by a
  8241. particular color. Text from these streams are displayed whenever
  8242. it is appropriate so there is often an intermixing of the text.
  8243. The distinction is only important if you choose to turn some of
  8244. the streams off or to direct some of the streams to text files.
  8245. On some systems you may be able to review the streams separately
  8246. in their own scroll-back buffer.
  8247.  
  8248. Here is a description of each stream.
  8249.  
  8250. Banner: This stream displays the program's sign-on banner,
  8251. copyright, contributor's list, and some help screens. It cannot
  8252. be turned off or directed to a file because most of this text is
  8253. displayed before any options or switches are read. Therefore you
  8254. cannot use an option or switch to control it. There are switches
  8255. which display the help screens. They are covered in section "Help
  8256. Screen Switches".
  8257.  
  8258. Debug: This stream displays debugging messages. It was primarily
  8259. designed for developers but this and other streams may also be
  8260. used by the user to display messages from within their scene
  8261. files. See section "Text Message Streams" for details on this
  8262. feature. This stream may be turned off and/or directed to a text
  8263. file.
  8264.  
  8265. Fatal: This stream displays fatal error messages. After
  8266. displaying this text, POV-Ray will terminate. When the error is a
  8267. scene parsing error, you may be shown several lines of scene text
  8268. that leads up to the error. This stream may be turned off and/or
  8269. directed to a text file.
  8270.  
  8271. Render: This stream displays information about what options you
  8272. have specified to render the scene. It includes feedback on all
  8273. of the major options such as scene name, resolution, animation
  8274. settings, anti-aliasing and others. This stream may be turned off
  8275. and/or directed to a text file.
  8276.  
  8277. Statistics: This stream displays statistics after a frame is
  8278. rendered. It includes information about the number of rays
  8279. traced, the length of time of the processing and other
  8280. information. This stream may be turned off and/or directed to a
  8281. text file.
  8282.  
  8283. Status: This stream displays one-line status messages that
  8284. explain what POV-Ray is doing at the moment. On some systems this
  8285. stream is displayed on a status line at the bottom of the screen.
  8286. This stream cannot be directed to a file because there is
  8287. generally no need to. The text displayed by the Verbose option or
  8288. +V switch is output to this stream so that part of the status
  8289. stream may be turned off.
  8290.  
  8291. Warning: This stream displays warning messages during the parsing
  8292. of scene files and other warnings. Despite the warning, POV-Ray
  8293. can continue to render the scene. You will be informed if POV-Ray
  8294. has made any assumptions about your scene so that it can proceed.
  8295. In general any time you see a warning, you should also assume
  8296. that this means that future versions of POV-Ray will not allow
  8297. the warned action. Therefore you should attempt to eliminate
  8298. warning messages so your scene will be able to run in future
  8299. versions of POV-Ray. This stream may be turned off and/or
  8300. directed to a text file.
  8301.  
  8302.  
  8303. 3.2.5.2   Console Text Output
  8304. Debug_Console=bool   Turn console display of
  8305.                      debug info text on/off
  8306. +GD                  Same as Debug_Console=On
  8307. -GD                  Same as Debug_Console=Off
  8308. Fatal_Console=bool   Turn console display of
  8309.                      fatal error text on/off
  8310. +GF                  Same as Fatal_Console=On
  8311. -GF                  Same as Fatal_Console=Off
  8312. Render_Console=bool  Turn console display of
  8313.                      render info text on/off
  8314. +GR                  Same as Render_Console=On
  8315. -GR                  Same as Render_Console=Off
  8316. Statistic_Console=bo Turn console display of
  8317. ol                   statistic text on/off
  8318. +GS                  Same as Statistic_Console=On
  8319. -GS                  Same as
  8320.                      Statistic_Console=Off
  8321. Warning_Console=bool Turn console display of
  8322.                      warning text on/off
  8323. +GW                  Same as Warning_Console=On
  8324. -GW                  Same as Warning_Console=Off
  8325. All_Console=bool     Turn on/off all debug,
  8326.                         fatal, render, statistic
  8327.                         and warning text to
  8328.                         console.
  8329. +GA                  Same as All_Console=On
  8330. -GA                  Same as All_Console=Off
  8331. You may suppress the output to the console of the debug, fatal,
  8332. render, statistic or warning text streams. For example the
  8333. Statistic_Console=off option or the -GS switch can turn off the
  8334. statistic stream. Using on or +GS you may turn it on again. You
  8335. may also turn all five of these streams on or off at once using
  8336. the All_Console option or +GA switch.
  8337.  
  8338. Note that these options take effect immediately when specified.
  8339. Obviously any error or warning messages that might occur before
  8340. the option is read are not be affected.
  8341.  
  8342.  
  8343. 3.2.5.3   Directing Text Streams to Files
  8344. Debug_File=true    Echo debug info text to DEBUG.OUT
  8345. Debug_File=false   Turn off file output of debug info
  8346. Debug_File=file      Echo debug info text to file
  8347. +GDfile            Both Debug_Console=On, Debug_File=file
  8348. -GDfile              Both Debug_Console=Off,
  8349.                    Debug_File=file
  8350. Fatal_File=true    Echo fatal text to FATAL.OUT
  8351. Fatal_File=false   Turn off file output of fatal
  8352. Fatal_File=file      Echo fatal info text to file
  8353. +GFfile            Both Fatal_Console=On, Fatal_File=file
  8354. -GFfile              Both Fatal_Console=Off,
  8355.                    Fatal_File=file
  8356. Render_File=true   Echo render info text to RENDER.OUT
  8357. Render_File=false  Turn off file output of render info
  8358. Render_File=file     Echo render info text to file
  8359. +GRfile            Both Render_Console=On,
  8360.                    Render_File=file
  8361. -GRfile              Both Render_Console=Off,
  8362.                    Render_File=file
  8363. Statistic_File=tr  Echo statistic text to STATS.OUT
  8364. ue
  8365. Statistic_File=fa  Turn off file output of statistics
  8366. lse
  8367. Statistic_File=file  Echo statistic text to file
  8368. +GSfile            Both Statistic_Console=On,
  8369.                      Statistic_File=file
  8370. -GSfile            Both Statistic_Console=Off,
  8371.                      Statistic_File=file
  8372. Warning_File=true  Echo warning info text to
  8373.                    WARNING.OUT
  8374. Warning_File=fals  Turn off file output of warning info
  8375. e
  8376. Warning_File=file    Echo warning info text to file
  8377. +GWfile            Both Warning_Console=On,
  8378.                    Warning_File=file
  8379. -GWfile              Both Warning_Console=Off,
  8380.                    Warning_File=file
  8381. All_File=true      Echo all debug, fatal, render,
  8382.                      statistic, and warning text to
  8383.                      ALLTEXT.OUT
  8384. All_File=false     Turn off file output of all debug,
  8385.                      fatal, render, statistic, and
  8386.                      warning text.
  8387. All_File=file        Echo all debug, fatal, render,
  8388.                    statistic, and warning text to file
  8389. +GAfile            Both All_Console=On, All_File=file
  8390. -GAfile              Both All_Console=Off, All_File=file
  8391. You may direct a copy of the text streams to a text file for the
  8392. debug, fatal, render, statistic, or warning text streams. For
  8393. example the Statistic_File=s option or the +GSs switch. If the
  8394. string s is true or any of the other valid true strings then that
  8395. stream is redirected to a file with a default name. Valid true
  8396. values are true, yes, on or 1. If the value is false the
  8397. direction to a text file is turned off. Valid false values are
  8398. false, no, off or 0. Any other string specified turns on file
  8399. output and the string is interpreted as the output file name.
  8400.  
  8401. Similarly you may specify such a true, false or file name string
  8402. after a switch such as +GSfile. You may also direct all five
  8403. streams to the same file using the All_File option or +GA switch.
  8404. You may not specify the same file for two or more streams because
  8405. POV-Ray will fail when it tries to open or close the same file
  8406. twice.
  8407.  
  8408. Note that these options take effect immediately when specified.
  8409. Obviously any error or warning messages that might occur before
  8410. the option is read will not be affected.
  8411.  
  8412.  
  8413. 3.2.5.4   Help Screen Switches
  8414. +H or +?       Show help screen 0 if this
  8415.                is the only switch
  8416. +H0 to +H8     Show help screen 0 to 8 if
  8417.                this is the only switch
  8418. +?0 to +?8     Same as +H0 to +H8
  8419. Note that there are no INI style equivalents to these options.
  8420.  
  8421. Graphical interface versions of POV-Ray such as Mac or Windows
  8422. have extensive online help. Other versions of POV-Ray have only a
  8423. few quick-reference help screens. The +? switch, optionally
  8424. followed by a single digit from 0 to 8, will display these help
  8425. screens to the banner text stream. After displaying the help
  8426. screens, POV-Ray terminates. Because some operating systems do
  8427. not permit a question mark as a command line switch you may also
  8428. use the +H switch. Note however that this switch is also used to
  8429. specify the height of the image in pixels. Therefore the +H
  8430. switch is only interpreted as a help switch if it is the only
  8431. switch on the command line and if the value after the switch is
  8432. less than or equal to 8.
  8433.  
  8434.  
  8435. 3.2.6     Tracing Options
  8436. There is more than one way to trace a ray. Sometimes there is a
  8437. trade-off between quality and speed. Sometimes options designed
  8438. to make tracing faster can slow things down. This section covers
  8439. options that tell POV-Ray how to trace rays with the appropriate
  8440. speed and quality settings.
  8441.  
  8442.  
  8443. 3.2.6.1   Quality Settings
  8444. Quality=  Set quality value to n
  8445. n         (0 <= n <= 11)
  8446. +Qn       Same as Quality=n
  8447. The Quality=n option or +Qn switch allows you to specify the
  8448. image rendering quality. You may choose to lower the quality for
  8449. test rendering and raise it for final renders. The quality
  8450. adjustments are made by eliminating some of the calculations that
  8451. are normally performed. For example settings below 4 do not
  8452. render shadows. Settings below 8 do not use reflection or
  8453. refraction. The duplicate values allow for future expansion.  The
  8454. values correspond to the following quality levels:
  8455. 0,  Just show quick colors. Use
  8456. 1      full ambient lighting only.
  8457.        Quick colors are used only at
  8458.        5 or below.
  8459. 2,  Show specified diffuse and
  8460. 3      ambient light.
  8461. 4   Render shadows, but no extended
  8462.        lights.
  8463. 5   Render shadows, including
  8464.        extended lights.
  8465. 6,  Compute texture patterns.
  8466. 7
  8467. 8   Compute reflected, refracted,
  8468.        and transmitted rays.
  8469. 9   Compute media.
  8470. 10  Compute radiosity but no media
  8471. 11  Compute radiosity and media
  8472. The default is 9 if not specified.
  8473.  
  8474.  
  8475. 3.2.6.2   Radiosity Setting
  8476. Radiosity=boo Turns radiosity
  8477. l             on/off
  8478. +QR           Turns radiosity on
  8479. -QR           Turns radiosity on
  8480. Radiosity is an additional calculation which computes diffuse
  8481. inter-reflection. It is an extremely slow calculation that is
  8482. somewhat experimental. By default, radiosity is off.  The
  8483. parameters which control how radiosity calculations are performed
  8484. are specified in the radiosity section of the global_settings
  8485. statement. See section "Radiosity" for further details.
  8486.  
  8487.  
  8488. 3.2.6.3   Automatic Bounding Control
  8489. Bounding=bool       Turn bounding on/off
  8490. +MB                 Turn bounding on; Set
  8491.                       threshold to 25 or
  8492.                       previous amount
  8493. -MB                 Turn bounding off
  8494. Bounding_Threshold  Set bound threshold to n
  8495. =n
  8496. +MBn                Turn bounding on; bound
  8497.                       threshold to n
  8498. -MBn                Turn bounding off; for
  8499.                       future threshold to n
  8500. Light_Buffer=bool   Turn light buffer on/off
  8501. +UL                 Turn light buffer on
  8502. -UL                 Turn light buffer off
  8503. Vista_Buffer=bool   Turn vista buffer on/off
  8504. +UV                 Turn vista buffer on
  8505. -UV                 Turn vista buffer off
  8506. POV-Ray uses a variety of spatial sub-division systems to speed
  8507. up ray-object intersection tests. The primary system uses a
  8508. hierarchy of nested bounding boxes. This system compartmentalizes
  8509. all finite objects in a scene into invisible rectangular boxes
  8510. that are arranged in a tree-like hierarchy. Before testing the
  8511. objects within the bounding boxes the tree is descended and only
  8512. those objects are tested whose bounds are hit by a ray. This can
  8513. greatly improve rendering speed. However for scenes with only a
  8514. few objects the overhead of using a bounding system is not worth
  8515. the effort. The Bounding=off option or -MB switch allows you to
  8516. force bounding off. The default value is on.
  8517.  
  8518. The Bounding_Threshold=n or +MBn switch allows you to set the
  8519. minimum number of objects necessary before bounding is used. The
  8520. default is +MB25 which means that if your scene has fewer than 25
  8521. objects POV-Ray will automatically turn bounding off because the
  8522. overhead isn't worth it. Generally it's a good idea to use a much
  8523. lower threshold like +MB5.
  8524.  
  8525. Additionally POV-Ray uses systems known as vista buffers and
  8526. light buffers to further speed things up. These systems only work
  8527. when bounding is on and when there are a sufficient number of
  8528. objects to meet the bounding threshold. The vista buffer is
  8529. created by projecting the bounding box hierarchy onto the screen
  8530. and determining the rectangular areas that are covered by each of
  8531. the elements in the hierarchy. Only those objects whose
  8532. rectangles enclose a given pixel are tested by the primary
  8533. viewing ray. The vista buffer can only be used with perspective
  8534. and orthographic cameras because they rely on a fixed viewpoint
  8535. and a reasonable projection (i. e. straight lines have to stay
  8536. straight lines after the projection).
  8537.  
  8538. The light buffer is created by enclosing each light source in an
  8539. imaginary box and projecting the bounding box hierarchy onto each
  8540. of its six sides. Since this relies on a fixed light source,
  8541. light buffers will not be used for area lights.
  8542.  
  8543. Reflected and transmitted rays do not take advantage of the light
  8544. and vista buffer.
  8545.  
  8546. The default settings are Vista_Buffer=on or +UV and
  8547. Light_Buffer=on or +UL. The option to turn these features off is
  8548. available to demonstrate their usefulness and as protection
  8549. against unforeseen bugs which might exist in any of these
  8550. bounding systems.
  8551.  
  8552. In general, any finite object and many types of CSG of finite
  8553. objects will properly respond to this bounding system. In
  8554. addition blobs and meshes use an additional internal bounding
  8555. system. These systems are not affected by the above switch. They
  8556. can be switched off using the appropriate syntax in the scene
  8557. file (see "Blob" and "Mesh" for details). Text objects are split
  8558. into individual letters that are bounded using the bounding box
  8559. hierarchy. Some CSG combinations of finite and infinite objects
  8560. are also automatically bound. The end result is that you will
  8561. rarely need to add manual bounding objects as was necessary in
  8562. earlier versions of POV-Ray unless you use many infinite objects.
  8563.  
  8564.  
  8565. 3.2.6.4   Removing User Bounding
  8566. Remove_Bounds=bo Turn unnecessary bounds
  8567. ol               removal on/off
  8568. +UR              Turn unnecessary bounds
  8569.                  removal on
  8570. -UR              Turn unnecessary bounds
  8571.                  removal off
  8572. Split_Unions=boo Turn split bounded unions
  8573. l                on/off
  8574. +SU              Turn split bounded unions on
  8575. -SU              Turn split bounded unions
  8576.                  off
  8577. Early versions of POV-Ray had no system of automatic bounding or
  8578. spatial sub-division to speed up ray-object intersection tests.
  8579. Users had to manually create bounding boxes to speed up the
  8580. rendering. Since version 3.0, POV-Ray has had more sophisticated
  8581. automatic bounding than any previous version. In many cases the
  8582. manual bounding on older scenes is slower than the new automatic
  8583. systems. Therefore POV-Ray removes manual bounding when it knows
  8584. it will help. In rare instances you may want to keep manual
  8585. bounding. Some older scenes incorrectly used bounding when they
  8586. should have used clipping. If POV-Ray removes the bounds in these
  8587. scenes the image will not look right. To turn off the automatic
  8588. removal of manual bounds you should specify Remove_Bounds=off or
  8589. use -UR. The default is Remove_Bounds=on.
  8590.  
  8591. One area where the jury is still out is the splitting of manually
  8592. bounded unions. Unbounded unions are always split into their
  8593. component parts so that automatic bounding works better. Most
  8594. users do not bound unions because they know that doing so is
  8595. usually slower. If you do manually bound a union we presume you
  8596. really want it bound. For safety sake we do not presume to remove
  8597. such bounds. If you want to remove manual bounds from unions you
  8598. should specify Split_Unions=on or use +SU. The default is
  8599. Split_Unions=off.
  8600.  
  8601.  
  8602. 3.2.6.5   Anti-Aliasing Options
  8603. Antialias=bool        Turns anti-aliasing on/off
  8604. +A                    Turns aa on with threshold 0.3 or
  8605.                       previous amount
  8606. -A                    Turns anti-aliasing off
  8607. Sampling_Method=n     Sets aa-sampling method (only 1 or 2
  8608.                       are valid)
  8609. +AMn                  Same as Sampling_Method=n
  8610. Antialias_Threshold=n Sets anti-aliasing threshold
  8611. .n
  8612. +An.n                 Sets aa on with aa-threshold at n.n
  8613. -An.n                 Sets aa off (aa-threshold n.n in
  8614.                       future)
  8615. Jitter=bool           Sets aa-jitter on/off
  8616. +J                    Sets aa-jitter on with 1.0 or previous
  8617.                       amount
  8618. -J                    Sets aa-jitter off
  8619. Jitter_Amount=n.n     Sets aa-jitter amount to n.n. If n.n
  8620.                       <= 0 aa-jitter is set off
  8621. +Jn.n                 Sets aa-jitter on; jitter amount to
  8622.                       n.n. If n.n <= 0 aa-jitter is set off
  8623. -Jn.n                 Sets aa-jitter off (jitter amount n.n
  8624.                       in future)
  8625. Antialias_Depth=n     Sets aa-depth (1 <= n <= 9)
  8626. +Rn                   Same as Antialias_Depth=n
  8627. The ray-tracing process is in effect a discrete, digital sampling
  8628. of the image with typically one sample per pixel. Such sampling
  8629. can introduce a variety of errors. This includes a jagged, stair-
  8630. step appearance in sloping or curved lines, a broken look for
  8631. thin lines, moirΘ patterns of interference and lost detail or
  8632. missing objects, which are so small they reside between adjacent
  8633. pixels. The effect that is responsible for those errors is called
  8634. aliasing.
  8635.  
  8636. Anti-aliasing is any technique used to help eliminate such errors
  8637. or to reduce the negative impact they have on the image. In
  8638. general, anti-aliasing makes the ray-traced image look smoother.
  8639. The Antialias=on option or +A switch turns on POV-Ray's anti-
  8640. aliasing system.
  8641.  
  8642. When anti-aliasing is turned on, POV-Ray attempts to reduce the
  8643. errors by shooting more than one viewing ray into each pixel and
  8644. averaging the results to determine the pixel's apparent color.
  8645. This technique is called super-sampling and can improve the
  8646. appearance of the final image but it drastically increases the
  8647. time required to render a scene since many more calculations have
  8648. to be done.
  8649.  
  8650. POV-Ray gives you the option to use one of two alternate super-
  8651. sampling methods. The Sampling_Method=n option or +AMn switch
  8652. selects either type 1 or type 2. Selecting one of those methods
  8653. does not turn anti-aliasing on. This has to be done by using the
  8654. +A command line switch or Antialias=on option.
  8655.  
  8656. Type 1 is an adaptive, non-recursive super-sampling method.  It
  8657. is adaptive because not every pixel is super-sampled.  Type 2 is
  8658. an adaptive and recursive super-sampling method.  It is recursive
  8659. because the pixel is sub-divided and sub-sub-divided recursively.
  8660. The adaptive nature of type 2 is the variable depth of recursion.
  8661.  
  8662. In the default, non-recursive method (+AM1), POV-Ray initially
  8663. traces one ray per pixel. If the color of a pixel differs from
  8664. its neighbors (to the left or above) by more than a threshold
  8665. value then the pixel is super-sampled by shooting a given, fixed
  8666. number of additional rays. The default threshold is 0.3 but it
  8667. may be changed using the Antialias_Threshold=n.n option. When the
  8668. switches are used, the threshold may optionally follow the +A.
  8669. For example +A0.1 turns anti-aliasing on and sets the threshold
  8670. to 0.1.
  8671.  
  8672. The threshold comparison is computed as follows. If r1, g1, b1
  8673. and r2, g2, b2 are the rgb components of two pixels then the
  8674. difference between pixels is computed by
  8675.  
  8676.   diff = abs(r1-r2) + abs(g1-g2) + abs(b1-b2)
  8677. If this difference is greater than the threshold then both pixels
  8678. are super-sampled. The rgb values are in the range from 0.0 to
  8679. 1.0 thus the most two pixels can differ is 3.0. If the anti-
  8680. aliasing threshold is 0.0 then every pixel is super-sampled. If
  8681. the threshold is 3.0 then no anti-aliasing is done. Lower
  8682. threshold means more anti-aliasing and less speed. Use anti-
  8683. aliasing for your final version of a picture, not the rough
  8684. draft. The lower the contrast, the lower the threshold should be.
  8685. Higher contrast pictures can get away with higher tolerance
  8686. values. Good values seem to be around 0.2 to 0.4.
  8687.  
  8688. When using the non-recursive method, the default number of super-
  8689. samples is nine per pixel, located on a 3*3 grid. The
  8690. Antialias_Depth=n option or +Rn switch controls the number of
  8691. rows and columns of samples taken for a super-sampled pixel. For
  8692. example +R4 would give 4*4=16 samples per pixel.
  8693.  
  8694. The second, adaptive, recursive super-sampling method starts by
  8695. tracing four rays at the corners of each pixel. If the resulting
  8696. colors differ more than the threshold amount additional samples
  8697. will be taken. This is done recursively, i.e. the pixel is
  8698. divided into four sub-pixels that are separately traced and
  8699. tested for further subdivision. The advantage of this method is
  8700. the reduced number of rays that have to be traced. Samples that
  8701. are common among adjacent pixels and sub-pixels are stored and
  8702. reused to avoid re-tracing of rays. The recursive character of
  8703. this method makes the super-sampling concentrate on those parts
  8704. of the pixel that are more likely to need super-sampling (see
  8705. figure below).
  8706.  
  8707.                                 
  8708.        Example of how the recursive super-sampling works.
  8709. The maximum number of subdivisions is specified by the
  8710. Antialias_Depth=n option or +Rn switch. This is different from
  8711. the adaptive, non-recursive method were the total number of super-
  8712. samples is specified. A maximum number of n subdivisions results
  8713. in a maximum number of samples per pixel that is given by the
  8714. following table.
  8715. +Rn     Number of      Maximum number of
  8716.        samples per          samples
  8717.       super-sampled    per super-sampled
  8718.       pixel for the        pixel for
  8719.       non-recursive      the recursive
  8720.        method +AM1        method +AM2
  8721.  1          1                  9
  8722.  2          4                 25
  8723.  3          9                 81
  8724.  4         16                 289
  8725.  5         25                1089
  8726.  6         36                4225
  8727.  7         49                16641
  8728.  8         64                66049
  8729.  9         81               263169
  8730. You should note that the maximum number of samples in the
  8731. recursive case is hardly ever reached for a given pixel. If the
  8732. recursive method is used with no anti-aliasing each pixel will be
  8733. the average of the rays traced at its corners. In most cases a
  8734. recursion level of three is sufficient.
  8735.  
  8736. Another way to reduce aliasing artifacts is to introduce noise
  8737. into the sampling process. This is called jittering and works
  8738. because the human visual system is much more forgiving to noise
  8739. than it is to regular patterns. The location of the super-samples
  8740. is jittered or wiggled a tiny amount when anti-aliasing is used.
  8741. Jittering is used by default but it may be turned off with the
  8742. Jitter=off option or -J switch. The amount of jittering can be
  8743. set with the Jitter_Amount=n.n option. When using switches the
  8744. jitter scale may be specified after the +Jn.n switch. For example
  8745. +J0.5 uses half the normal jitter. The default amount of 1.0 is
  8746. the maximum jitter which will insure that all super-samples
  8747. remain inside the original pixel. Note that the jittering noise
  8748. is random and non-repeatable so you should avoid using jitter in
  8749. animation sequences as the anti-aliased pixels will vary and
  8750. flicker annoyingly from frame to frame.
  8751.  
  8752. If anti-aliasing is not used one sample per pixel is taken
  8753. regardless of the super-sampling method specified.
  8754.  
  8755.  
  8756. 4    Scene Description Language
  8757. The reference section describes the POV-Ray scene description
  8758. language.  It is supposed to be used as a reference for looking
  8759. up things. It does not contain detailed explanations on how
  8760. scenes are written or how POV-Ray is used. It just explains all
  8761. features, their syntax, applications, limits, drawbacks, etc.
  8762.  
  8763. The scene description language allows you to describe the world
  8764. in a readable and convenient way. Files are created in plain
  8765. ASCII text using an editor of your choice. The input file name is
  8766. specified using the Input_File_Name=file option or +Ifile switch.
  8767. By default the files have the extension .pov. POV-Ray reads the
  8768. file, processes it by creating an internal model of the scene and
  8769. then renders the scene.
  8770.  
  8771. The overall syntax of a scene is shown below.  See "Notation and
  8772. Basic Assumptions" for more information on syntax notation.
  8773.  
  8774. SCENE:
  8775.   SCENE_ITEM...
  8776. SCENE_ITEM:
  8777.   LANGUAGE_DIRECTIVES      |
  8778.   camera { CAMERA_ITEMS... }    |
  8779.   OBJECTS                  |
  8780.   ATMOSPHERIC_EFFECTS      |
  8781.   global_settings { GLOBAL_ITEMS }
  8782. In plain English, this means that a scene contains one or more
  8783. scene items and that a scene item may be any of the five items
  8784. listed below it.  The items may appear in any order.  None is a
  8785. required item.  In addition to the syntax depicted above, a
  8786. LANGUAGE_DIRECTIVE may also appear anywhere embedded in other
  8787. statements between any two tokens.  There are some restrictions
  8788. on nesting directives also.
  8789.  
  8790. For details on those five items see section "Language
  8791. Directives", section "Objects", section "Camera", section
  8792. "Atmospheric Effects" and section "Global Settings" for details.
  8793.  
  8794.  
  8795. 4.1  Language Basics
  8796. The POV-Ray language consists of identifiers, reserved keywords,
  8797. floating point expressions, strings, special symbols and
  8798. comments. The text of a POV-Ray scene file is free format. You
  8799. may put statements on separate lines or on the same line as you
  8800. desire. You may add blank lines, spaces or indentations as long
  8801. as you do not split any keywords or identifiers.
  8802.  
  8803.  
  8804. 4.1.1     Identifiers and Keywords
  8805. POV-Ray allows you to define identifiers for later use in the
  8806. scene file. An identifier may be 1 to 40 characters long. It may
  8807. consist of upper or lower case letters, the digits 0 through 9 or
  8808. an underscore character ("_"). The first character must be an
  8809. alphabetic character. The declaration of identifiers is covered
  8810. later.
  8811.  
  8812. POV-Ray has a number of reserved keywords which are listed below.
  8813. abs        dimension_s  merge        sky_sphere
  8814. absorption ize          mesh         slice
  8815. acos       direction    metallic     slope_map
  8816. acosh      disc         min          smooth
  8817. adaptive   distance     minimum_reu  smooth_tri
  8818. adc_bailou distance_ma  se           angle
  8819. t          ximum        mod          sor
  8820. agate      div          mortar       specular
  8821. agate_turb eccentricit  nearest_cou  sphere
  8822. all        y            nt           spherical
  8823. alpha      else         no           spiral1
  8824. ambient    emission     normal       spiral2
  8825. ambient_li end          normal_map   spotlight
  8826. ght        error        no_shadow    spotted
  8827. angle      error_bound  number_of_w  sqr
  8828. aperture   exp          aves         sqrt
  8829. append     extinction   object       statistics
  8830. arc_angle  fade_distan  octaves      str
  8831. area_light ce           off          strcmp
  8832. array      fade_power   offset       strength
  8833. asc        falloff      omega        strlen
  8834. asin       falloff_ang  omnimax      strlwr
  8835. asinh      le           on           strupr
  8836. assumed_ga false        once         sturm
  8837. mma        fclose       onion        substr
  8838. atan       file_exists  open         superellip
  8839. atan2      filter       orthographi  soid
  8840. atanh      finish       c            switch
  8841. average    fisheye      panoramic    sys
  8842. background flatness     perspective  t
  8843. bezier_spl flip         pgm          tan
  8844. ine        floor        phase        tanh
  8845. bicubic_pa focal_point  phong        text
  8846. tch        fog          phong_size   texture
  8847. black_hole fog_alt      pi           texture_ma
  8848. blob       fog_offset   pigment      p
  8849. blue       fog_type     pigment_map  tga
  8850. blur_sampl fopen        planar       thickness
  8851. es         frequency    plane        threshold
  8852. bounded_by gif          png          tightness
  8853. box        global_sett  point_at     tile2
  8854. boxed      ings         poly         tiles
  8855. bozo       gradient     polygon      torus
  8856. break      granite      poly_wave    track
  8857. brick      gray_thresh  pot          transform
  8858. brick_size old          pow          translate
  8859. brightness green        ppm          transmit
  8860. brilliance height_fiel  precision    triangle
  8861. bumps      d            prism        triangle_w
  8862. bump_map   hexagon      pwr          ave
  8863. bump_size  hf_gray_16   quadratic_s  true
  8864. camera     hierarchy    pline        ttf
  8865. case       hollow       quadric      turbulence
  8866. caustics   hypercomple  quartic      turb_depth
  8867. ceil       x            quaternion   type
  8868. checker    if           quick_color  u
  8869. chr        ifdef        quick_colou  ultra_wide
  8870. clipped_by iff          r            _angle
  8871. clock      ifndef       quilted      undef
  8872. clock_delt image_map    radial       union
  8873. a          include      radians      up
  8874. color      int          radiosity    use_color
  8875. color_map  interior     radius       use_colour
  8876. colour     interpolate  rainbow      use_index
  8877. colour_map intersectio  ramp_wave    u_steps
  8878. component  n            rand         v
  8879. composite  intervals    range        val
  8880. concat     inverse      ratio        variance
  8881. cone       ior          read         vaxis_rota
  8882. confidence irid         reciprocal   te
  8883. conic_swee irid_wavele  recursion_l  vcross
  8884. p          ngth         imit         vdot
  8885. control0   jitter       red          version
  8886. control1   julia_fract  reflection   vlength
  8887. cos        al           reflection_  vnormalize
  8888. cosh       lambda       exponent     vrotate
  8889. count      lathe        refraction   v_steps
  8890. crackle    leopard      render       warning
  8891. crand      light_sourc  repeat       warp
  8892. cube       e            rgb          water_leve
  8893. cubic      linear_spli  rgbf         l
  8894. cubic_spli ne           rgbft        waves
  8895. ne         linear_swee  rgbt         while
  8896. cubic_wave p            right        width
  8897. cylinder   local        ripples      wood
  8898. cylindrica location     rotate       wrinkles
  8899. l          log          roughness    write
  8900. debug      looks_like   samples      x
  8901. declare    look_at      scale        y
  8902. default    low_error_f  scallop_wav  yes
  8903. defined    actor        e            z
  8904. degrees    macro        scattering
  8905. density    mandel       seed
  8906. density_fi map_type     shadowless
  8907. le         marble       sin
  8908. density_ma material     sine_wave
  8909. p          material_ma  sinh
  8910. dents      p            sky
  8911. difference matrix
  8912. diffuse    max
  8913. dimensions max_interse
  8914.            ctions
  8915.            max_iterati
  8916.            on
  8917.            max_trace_l
  8918.            evel
  8919.            media
  8920.            media_atten
  8921.            uation
  8922.            media_inter
  8923.            action
  8924. All reserved words are fully lower case. Therefore it is
  8925. recommended that your identifiers contain at least one upper case
  8926. character so it is sure to avoid conflict with reserved words.
  8927.  
  8928.  
  8929. 4.1.2     Comments
  8930. Comments are text in the scene file included to make the scene
  8931. file easier to read or understand. They are ignored by the ray-
  8932. tracer and are there for your information. There are two types of
  8933. comments in POV-Ray.
  8934.  
  8935. Two slashes are used for single line comments. Anything on a line
  8936. after a double slash (//) is ignored by the ray-tracer. For
  8937. example:
  8938.  
  8939.  // This line is ignored
  8940. You can have scene file information on the line in front of the
  8941. comment as in:
  8942.  
  8943.  object { FooBar } // this is an object
  8944. The other type of comment is used for multiple lines. It starts
  8945. with "/*" and ends with "*/". Everything in-between is ignored.
  8946. For example:
  8947.  
  8948.  /* These lines
  8949.    are ignored
  8950.    by the
  8951.    ray-tracer */
  8952. This can be useful if you want to temporarily remove elements
  8953. from a scene file. /* ... */ comments can comment out lines
  8954. containing other // comments and thus can be used to temporarily
  8955. or permanently comment out parts of a scene. /* ... */ comments
  8956. can be nested, the following is legal:
  8957.  
  8958.  /* This is a comment
  8959.  // This too
  8960.  /* This also */
  8961.  */
  8962. Use comments liberally and generously. Well used, they really
  8963. improve the readability of scene files.
  8964.  
  8965.  
  8966. 4.1.3     Float Expressions
  8967. Many parts of the POV-Ray language require you to specify one or
  8968. more floating point numbers. A floating point number is a number
  8969. with a decimal point. Floats may be specified using literals,
  8970. identifiers or functions which return float values. You may also
  8971. create very complex float expressions from combinations of any of
  8972. these using various familiar operators.
  8973.  
  8974. Where POV-Ray needs an integer value it allows you to specify a
  8975. float value and it truncates it to an integer. When POV-Ray needs
  8976. a logical or boolean value it interprets any non-zero float as
  8977. true and zero as false. Because float comparisons are subject to
  8978. rounding errors POV-Ray accepts values extremely close to zero as
  8979. being false when doing boolean functions. Typically values whose
  8980. absolute values are less than a preset value epsilon are
  8981. considered false for logical expressions. The value of epsilon is
  8982. system dependent but is generally about 1.0e-10. Two floats a and
  8983. b are considered to be equal if abs(a-b) < epsilon.
  8984.  
  8985. The full syntax for float expressions is given below.  Detailed
  8986. explanations are given in the following sub-sections.
  8987.  
  8988. FLOAT:
  8989.   NUMERIC_TERM  [SIGN  NUMERIC_TERM]
  8990. SIGN:
  8991.   +    |    -
  8992. NUMERIC_TERM:
  8993.   NUMERIC_FACTOR  [MULT  NUMERIC_FACTOR]
  8994. MULT:
  8995.   *    |    /
  8996. NUMERIC_FACTOR:
  8997.   FLOAT_LITERAL       |
  8998.   FLOAT_IDENTIFIER         |
  8999.   SIGN  NUMERIC_FACTOR     |
  9000.   FLOAT_FUNCTION      |
  9001.   FLOAT_BUILT-IN_IDENT     |
  9002.   ( FULL_EXPRESSION ) |
  9003.   !  NUMERIC_FACTOR   |
  9004.   VECTOR DECIMAL_POINT DOT_ITEM
  9005.   
  9006. FLOAT_LITERAL:
  9007.   [DIGIT...] [DECIMAL_POINT] DIGIT... [EXP [SIGN] DIGIT...]
  9008. DIGIT:
  9009.   0   |   1   |   2   |   3   |   4   |   5   |   6   |   7   |
  9010.   8   |   9
  9011. DECIMAL_POINT:
  9012.   .
  9013. EXP:
  9014.   e   |   E
  9015. DOT_ITEM:
  9016.   x   |   y   |   z   |   t   |   u   |   v   |   red   |   blue
  9017.   |   green   |   filter   |   transmit
  9018. FLOAT_FUNCTION:
  9019.   abs( FLOAT )   |   acos( FLOAT )   |   val( STRING )   |
  9020.   asc( STRING )   |
  9021.   asin( FLOAT )   |   atan2( FLOAT , FLOAT )   |   ceil( FLOAT )
  9022.   |   cos( FLOAT )   |
  9023.   defined(IDENTIFIER )   |   degrees( FLOAT )   |   div( FLOAT ,
  9024.   FLOAT )   |   exp( FLOAT )   |
  9025.   file_exists( STRING )   |   floor( FLOAT )   |   int( FLOAT )
  9026.   |   log( FLOAT )   |
  9027.   max( FLOAT , FLOAT )   |   min( FLOAT , FLOAT )   |   mod(
  9028.   FLOAT , FLOAT )   |
  9029.   pow( FLOAT , FLOAT )   |   radians( FLOAT )   |   sin( FLOAT )
  9030.   |   sqrt( FLOAT )   |
  9031.   strcmp( STRING , STRING )   |   strlen( STRING )   |   tan(
  9032.   FLOAT )   |
  9033.   vdot( VECTOR , VECTOR )   |   vlength( VECTOR )   |   seed(
  9034.   FLOAT )   |   rand( FLOAT )   |
  9035.   dimensions( ARRAY_IDENTIFIER )   |   dimension_size(
  9036.   ARRAY_IDENTIFIER , FLOAT )
  9037. FLOAT_BUILT-IN_IDENT:
  9038.   clock   |   pi   |   version   |   true   |   yes   |   on   |
  9039.   false   |   no   |
  9040.   off   |   clock_delta
  9041. FULL_EXPRESSION:
  9042.   LOGICAL_EXPRESSION  [? FULL_EXPRESSION : FULL_EXPRESSION]
  9043. LOGICAL_EXPRESSION:
  9044.   REL_TERM  [LOGICAL_OPERATOR  REL_TERM]
  9045. LOGICAL_OPERATOR:
  9046.   &   |   |        (note this means an ampersand or a vertical
  9047.   bar is a logical operator)
  9048. REL_TERM:
  9049.   FLOAT  [REL_OPERATOR  FLOAT]
  9050. REL_OPERATOR:
  9051.   <   |   <=   |   =   |   >=   |   >   |   !=
  9052. INT:
  9053.   FLOAT     (note any syntax which requires a integer INT will
  9054.   accept a FLOAT and it will be truncated
  9055.             to an integer internally by POV-Ray).
  9056. Note: FLOAT_IDENTIFIERS are identifiers previously declared to
  9057. have float values.  The DOT_ITEM syntax is actually a vector or
  9058. color operator but it returns a float value.  See "Vector
  9059. Operators" or "Color Operators" for details.  An ARRAY_IDENTIFIER
  9060. is just the identifier name of a previously declared array, it
  9061. does not include the [] braces nor the index.  The syntax for
  9062. STRING is in the section "Strings".
  9063.  
  9064.  
  9065. 4.1.3.1   Float Literals
  9066. Float literals are represented by an optional sign ("+" or "-")
  9067. digits, an optional decimal point and more digits. If the number
  9068. is an integer you may omit the decimal point and trailing zero.
  9069. If it is all fractional you may omit the leading zero. POV-Ray
  9070. supports scientific notation for very large or very small
  9071. numbers. The following are all valid float literals:
  9072.  
  9073.  -2.0  -4  34  3.4e6  2e-5  .3  0.6
  9074.  
  9075. 4.1.3.2   Float Identifiers
  9076. Float identifiers may be declared to make scene files more
  9077. readable and to parameterize scenes so that changing a single
  9078. declaration changes many values. An identifier is declared as
  9079. follows.
  9080.  
  9081. FLOAT_DECLARATION:
  9082.   #declare IDENTIFIER = EXPRESSION;  |
  9083.   #local IDENTIFIER = EXPRESSION;
  9084. Where IDENTIFIER is the name of the identifier up to 40
  9085. characters long and EXPRESSION is any valid expression which
  9086. evaluates to a float value. Note that there should be a semi-
  9087. colon after the expression in a float declaration. This semi-
  9088. colon is new with POV-Ray version 3.1. If omitted, it generates a
  9089. warning and some macros may not work properly. See "#declare vs.
  9090. #local" for information on identifier scope.  Here are some
  9091. examples.
  9092.  
  9093.  #declare Count = 0;
  9094.  #declare Rows = 5.3;
  9095.  #declare Cols = 6.15;
  9096.  #declare Number = Rows*Cols;
  9097.  #declare Count = Count+1;
  9098. As the last example shows, you can re-declare a float identifier
  9099. and may use previously declared values in that re-declaration.
  9100. There are several built-in identifiers which POV-Ray declares for
  9101. you. See "Built-in Float Identifiers" for details.
  9102.  
  9103.  
  9104. 4.1.3.3   Float Operators
  9105. Arithmetic expressions: Basic math expressions can be created
  9106. from float literals, identifiers or functions using the following
  9107. operators in this order of precedence...
  9108. (  )      expressions in
  9109.           parentheses first
  9110. +A  -A    unary minus, unary plus
  9111. !A        and logical "not"
  9112. A*B A/B   multiplication and
  9113.           division
  9114. A+B A-B   addition and
  9115.           subtraction
  9116. Relational, logical and conditional expressions may also be
  9117. created. However there is a restriction that these types of
  9118. expressions must be enclosed in parentheses first. This
  9119. restriction, which is not imposed by most computer languages, is
  9120. necessary because POV-Ray allows mixing of float and vector
  9121. expressions. Without the parentheses there is an ambiguity
  9122. problem. Parentheses are not required for the unary logical not
  9123. operator "!" as shown above. The operators and their precedence
  9124. are shown here.
  9125.  
  9126. Relational expressions: The operands are arithmetic expressions
  9127. and the result is always boolean with 1 for true and 0 for false.
  9128. All relational operators have the same precedence.
  9129.  
  9130.  
  9131. (A < B)   A is less than B
  9132. (A <= B)  A is less than or equal to B
  9133. (A = B)   A is equal to B (actually abs(A-
  9134.           B)<EPSILON)
  9135. (A != B)  A is not equal to B (actually
  9136.           abs(A-B)>=EPSILON)
  9137. (A >= B)  A is greater than or equal to B
  9138. (A > B)   A is greater than B
  9139. Logical expressions: The operands are converted to boolean values
  9140. of 0 for false and 1 for true. The result is always boolean. All
  9141. logical operators have the same precedence. Note that these are
  9142. not bit-wise operations, they are logical.
  9143. (A & B)   true only if both A and B are
  9144.           true, false otherwise
  9145. (A | B)   true if either A or B or both
  9146.           are true
  9147. Conditional expressions: The operand C is boolean while operands
  9148. A and B are any expressions. The result is of the same type as A
  9149. and B.
  9150. (C ? A : B) if C then A else B
  9151. Assuming the various identifiers have been declared, the
  9152. following are examples of valid expressions...
  9153.  
  9154. 1+2+3    2*5     1/3     Row*3    Col*5
  9155. (Offset-5)/2      This/That+Other*Thing
  9156. ((This<That) & (Other>=Thing)?Foo:Bar)
  9157. Expressions are evaluated left to right with innermost
  9158. parentheses evaluated first, then unary +, - or !, then multiply
  9159. or divide, then add or subtract, then relational, then logical,
  9160. then conditional.
  9161.  
  9162.  
  9163. 4.1.3.4   Built-in Float Identifiers
  9164. There are several built-in float identifiers. You can use them to
  9165. specify values or to create expressions but you cannot re-declare
  9166. them to change their values.  They are:
  9167.  
  9168. FLOAT_BUILT-IN_IDENT:
  9169.   clock   |   pi   |   version   |   true   |   yes   |   on   |
  9170.   false   |   no   |
  9171.   off   |   clock_delta
  9172. Most built-in identifiers never change value. They are defined as
  9173. though the following lines were at the start of every scene.
  9174.  
  9175.  #declare pi = 3.1415926535897932384626;
  9176.  #declare true = 1;
  9177.  #declare yes = 1;
  9178.  #declare on = 1;
  9179.  #declare false = 0;
  9180.  #declare no = 0;
  9181.  #declare off = 0;
  9182. The built-in float identifier pi is obviously useful in math
  9183. expressions involving circles.  The built-in float identifiers
  9184. on, off, yes, no, true, and false are designed for use as boolean
  9185. constants.
  9186.  
  9187. The built-in float identifier clock is used to control animations
  9188. in POV-Ray. Unlike some animation packages, the action in POV-Ray
  9189. animated scenes does not depend upon the integer frame numbers.
  9190. Rather you should design your scenes based upon the float
  9191. identifier clock. For non-animated scenes its default value is 0
  9192. but you can set it to any float value using the INI file option
  9193. Clock=n.n or the command-line switch +Kn.n to pass a single float
  9194. value your scene file.
  9195.  
  9196. Other INI options and switches may be used to animate scenes by
  9197. automatically looping through the rendering of frames using
  9198. various values for clock. By default, the clock value is 0 for
  9199. the initial frame and 1 for the final frame. All other frames are
  9200. interpolated between these values. For example if your object is
  9201. supposed to rotate one full turn over the course of the animation
  9202. you could specify rotate 360*clock*y. Then as clock runs from 0
  9203. to 1, the object rotates about the y-axis from 0 to 360 degrees.
  9204.  
  9205. Although the value of clock will change from frame-to-frame, it
  9206. will never change throughout the parsing of a scene.
  9207.  
  9208. The built-in float identifier clock_delta returns the amount of
  9209. time between clock values in animations in POV-Ray. While most
  9210. animations only need the clock value itself, some animation
  9211. calculations are easier if you know how long since the last
  9212. frame. Caution must be used when designing such scenes. If you
  9213. render a scene with too few frames, the results may be different
  9214. than if you render with more frames in a given time period.  On
  9215. non-animated scenes, clock_delta defaults to 1.0.  See section
  9216. "Animation Options" for more details.
  9217.  
  9218. The built-in float identifier version contains the current
  9219. setting of the version compatibility option. Although this value
  9220. defaults to 3.1 which is the current POV-Ray version number, the
  9221. initial value of version may be set by the INI file option
  9222. Version=n.n or by the +MVn.n command-line switch. This tells POV-
  9223. Ray to parse the scene file using syntax from an earlier version
  9224. of POV-Ray.
  9225.  
  9226. The INI option or switch only affects the initial setting. Unlike
  9227. other built-in identifiers, you may change the value of version
  9228. throughout a scene file. You do not use #declare to change it
  9229. though. The #version language directive is used to change modes.
  9230. Such changes may occur several times within scene files.
  9231.  
  9232. Together with the built-in version identifier the #version
  9233. directive allows you to save and restore the previous values of
  9234. this compatibility setting. The new #local identifier option is
  9235. especially useful here. For example suppose mystuff.inc is in
  9236. version 1 format. At the top of the file you could put:
  9237.  
  9238.  #local Temp_Vers = version;  // Save previous value
  9239.  #version 1.0;         // Change to 1.0 mode
  9240.  ... // Version 1.0 stuff goes here...
  9241.  #version Temp_Vers;      // Restore previous version
  9242. Note that there should be a semi-colon after the float expression
  9243. in a #version directive. This semi-colon is new with POV-Ray
  9244. version 3.1. If omitted, it generates a warning and some macros
  9245. may not work properly.
  9246.  
  9247.  
  9248. 4.1.3.5   Boolean Keywords
  9249. The built-in float identifiers on, off, yes, no, true, and false
  9250. are most often used as boolean values with object modifiers or
  9251. parameters such as sturm, hollow, hierarchy, smooth,
  9252. media_attenuation, and media_interaction.  Whenever you see
  9253. syntax of the form keyword [Bool], if you simply specify the
  9254. keyword without the optional boolean then it assumes keyword on.
  9255. You need not use the boolean but for readability it is a good
  9256. idea.  You must use one of the false booleans or an expression
  9257. which evaluates to zero to turn it off.  Note some of these
  9258. keywords default on if no keyword is specified.  For example:
  9259.  
  9260.   object{MyBlob}  //sturm defaults off but hierarchy defaults on
  9261.   object{MyBlob sturm}      //turn sturm on
  9262.   object{MyBlob sturm on}   //turn sturm on
  9263.   object{MyBlob sturm off}  //turn sturm off
  9264.   object{MyBlob hierarchy}  //does nothing, hierarchy was already
  9265. on
  9266.   object{MyBlob hierarchy off}  //turn hierarchy off
  9267.  
  9268. 4.1.3.6   Float Functions
  9269. POV-Ray defines a variety of built-in functions for manipulating
  9270. floats, vectors and strings. Function calls consist of a keyword
  9271. which specifies the name of the function followed by a parameter
  9272. list enclosed in parentheses. Parameters are separated by commas.
  9273. For example:
  9274.  
  9275.  keyword(param1,param2)
  9276. The following are the functions which return float values. They
  9277. take one or more float, integer, vector, or string parameters.
  9278. Assume that A and B are any valid expression that evaluates to a
  9279. float; I is a float which is truncated to integer internally, S,
  9280. S1, S2 etc. are strings, and V, V1, V2 etc. are any vector
  9281. expressions.
  9282.  
  9283. abs(A)    Absolute value of A. If A is negative, returns -A
  9284. otherwise returns A.
  9285.  
  9286. acos(A)   Arc-cosine of A. Returns the angle, measured in
  9287. radians, whose cosine is A.
  9288.  
  9289. asc(S)    Returns an integer value in the range 0 to 255 that is
  9290. the ASCII value of the first character of the string S. For
  9291. example asc("ABC") is 65 because that is the value of the
  9292. character "A".
  9293.  
  9294. asin(A)   Arc-sine of A. Returns the angle, measured in radians,
  9295. whose sine is A.
  9296.  
  9297. atan2(A,B)     Arc-tangent of (A/B). Returns the angle, measured
  9298. in radians, whose tangent is (A/B). Returns appropriate value
  9299. even if B is zero. Use atan2(A,1) to compute usual atan(A)
  9300. function.
  9301.  
  9302. ceil(A)   Ceiling of A. Returns the smallest integer greater than
  9303. A. Rounds up to the next higher integer.
  9304.  
  9305. cos(A)    Cosine of A. Returns the cosine of the angle A, where A
  9306. is measured in radians.
  9307.  
  9308. defined(IDENTIFIER )     Returns true if the identifier is
  9309. currently defined, false otherwise.  This is especially useful
  9310. for detecting end-of-file after a #read directive because the
  9311. file identifer is automatically undefined when end-of-file is
  9312. reached.  See "The #read Directive" for details.
  9313.  
  9314. degrees(A)     Convert radians to degrees. Returns the angle
  9315. measured in degrees whose value in radians is A. Formula is
  9316. degrees=A/pi*180.0.
  9317.  
  9318. dimensions( ARRAY_IDENTIFIER )     Returns the number of
  9319. dimensions of a previously declared array identifier.  For
  9320. example if you do #declare MyArray=array[6][10] then
  9321. dimensions(MyArray) returns the value 2.
  9322.  
  9323. dimension_size( ARRAY_IDENTIFIER, FLOAT )    Returns the size of
  9324. a given dimension of a previously declared array identifier.
  9325. Dimensions are numbered left-to-right starting with 1. For
  9326. example if you do #declare MyArray=array[6][10] then
  9327. dimension_size(MyArray,2) returns the value 10.
  9328.  
  9329. div(A,B)  Integer division. The integer part of (A/B).
  9330.  
  9331. exp(A)    Exponential of A. Returns the value of e raised to the
  9332. power A where e is the base of the natural logarithm, i.e. the
  9333. non-repeating value approximately equal to 2.71828182846.
  9334.  
  9335. file_exists(S) Attempts to open the file specified by the string
  9336. S. The current directory and all library directories specified by
  9337. the Library_Path or +L options are also searched.  See "Library
  9338. Paths" for details.  Returns 1 if successful and 0 if
  9339. unsuccessful.
  9340.  
  9341. floor(A)  Floor of A. Returns the largest integer less than A.
  9342. Rounds down to the next lower integer.
  9343.  
  9344. int(A)    Integer part of A. Returns the truncated integer part
  9345. of A. Rounds towards zero.
  9346.  
  9347. log(A)    Natural logarithm of A. Returns the natural logarithm
  9348. base e of the value A.
  9349.  
  9350. max(A,B)  Maximum of A and B. Returns A if A larger than B.
  9351. Otherwise returns B.
  9352.  
  9353. min(A,B)  Minimum of A and B. Returns A if A smaller than B.
  9354. Otherwise returns B.
  9355.  
  9356. mod(A,B)  Value of A modulo B. Returns the remainder after the
  9357. integer division of A/B. Formula is mod=((A/B)-int(A/B))*B.
  9358.  
  9359. pow(A,B)  Exponentiation. Returns the value of A raised to the
  9360. power B.
  9361.  
  9362. radians(A)     Convert degrees to radians. Returns the angle
  9363. measured in radians whose value in degrees is A. Formula is
  9364. radians=A*pi/180.0.
  9365.  
  9366. rand(I)   Returns the next pseudo-random number from the stream
  9367. specified by the positive integer I. You must call seed() to
  9368. initialize a random stream before calling rand(). The numbers are
  9369. uniformly distributed, and have values between 0.0 and 1.0,
  9370. inclusively. The numbers generated by separate streams are
  9371. independent random variables.
  9372.  
  9373. seed(A)   Initializes a new pseudo-random stream with the initial
  9374. seed value A. The number corresponding to this random stream is
  9375. returned. Any number of pseudo-random streams may be used as
  9376. shown in the example below:
  9377.  
  9378.  #declare R1 = seed(0);
  9379.  #declare R2 = seed(12345);
  9380.  #sphere { <rand(R1), rand(R1), rand(R1)>, rand(R2) }
  9381. Multiple random generators are very useful in situations where
  9382. you use rand() to place a group of objects, and then decide to
  9383. use rand() in another location earlier in the file to set some
  9384. colors or place another group of objects. Without separate rand()
  9385. streams, all of your objects would move when you added more calls
  9386. to rand(). This is very annoying.
  9387.  
  9388. sin(A)    Sine of A. Returns the sine of the angle A, where A is
  9389. measured in radians.
  9390.  
  9391. strcmp(S1,S2)  Compare string S1 to S2. Returns a float value
  9392. zero if the strings are equal, a positive number if S1 comes
  9393. after S2 in the ASCII collating sequence, else a negative number.
  9394.  
  9395. strlen(S) Length of S. Returns an integer value that is the
  9396. number of characters in the string S.
  9397.  
  9398. sqrt(A)   Square root of A. Returns the value whose square is A.
  9399.  
  9400. tan(A)    Tangent of A. Returns the tangent of the angle A, where
  9401. A is measured in radians.
  9402.  
  9403. val(S)    Convert string S to float. Returns a float value that
  9404. is represented by the text in string S. For example val("123.45")
  9405. is 123.45 as a float.
  9406.  
  9407. vdot(V1,V2)    Dot product of V1 and V2. Returns a float value
  9408. that is the dot product (sometimes called scalar product of V1
  9409. with V2. Formula is vdot=V1.x*V2.x + V1.y*V2.y + V1.z*V2.z. See
  9410. the animated demo scene VECT2.POV for an illustration.
  9411.  
  9412. vlength(V)     Length of V. Returns a float value that is the
  9413. length of vector V. Formula is vlength=sqrt(vdot(A,A)).  Can be
  9414. used to compute the distance between two points. Dist=vlength(V2-
  9415. V1).
  9416.  
  9417. See section "Vector Functions" and section "String Functions" for
  9418. other functions which are somewhat float-related but which return
  9419. vectors and strings.  In addition to the above built-in
  9420. functions, you may also define your own functions using the new
  9421. #macro directive. See the section "User Defined Macros" for more
  9422. details.
  9423.  
  9424.  
  9425. 4.1.4     Vector Expressions
  9426. POV-Ray often requires you to specify a vector. A vector is a set
  9427. of related float values. Vectors may be specified using literals,
  9428. identifiers or functions which return vector values. You may also
  9429. create very complex vector expressions from combinations of any
  9430. of these using various familiar operators.
  9431.  
  9432. POV-Ray vectors may have from two to five components but the vast
  9433. majority of vectors have three components. Unless specified
  9434. otherwise, you should assume that the word "vector" means a three
  9435. component vector. POV-Ray operates in a 3D x, y, z coordinate
  9436. system and you will use three component vectors to specify x, y
  9437. and z values. In some places POV-Ray needs only two coordinates.
  9438. These are often specified by a 2D vector called an UV vector.
  9439. Fractal objects use 4D vectors. Color expressions use 5D vectors
  9440. but allow you to specify 3, 4 or 5 components and use default
  9441. values for the unspecified components. Unless otherwise noted,
  9442. all 2, 4 or 5 component vectors work just like 3D vectors but
  9443. they have a different number of components.
  9444.  
  9445. The syntax for combining vector literals into vector expressions
  9446. is almost identical to the rules for float expressions.  In the
  9447. syntax for vector expressions below, some of the syntax items are
  9448. defined in the section for float expressions.  See "Float
  9449. Expressions" for those definitions.  Detailed explanations of
  9450. vector-specific issues are given in the following sub-sections.
  9451.  
  9452. VECTOR:
  9453.   NUMERIC_TERM  [SIGN  NUMERIC_TERM]
  9454. NUMERIC_TERM:
  9455.   NUMERIC_FACTOR  [MULT  NUMERIC_FACTOR]
  9456. NUMERIC_FACTOR:
  9457.   VECTOR_LITERAL      |
  9458.   VECTOR_IDENTIFIER   |
  9459.   SIGN  NUMERIC_FACTOR     |
  9460.   VECTOR_FUNCTION     |
  9461.   VECTOR_BUILT-IN_IDENT    |
  9462.   ( FULL_EXPRESSION ) |
  9463.   !  NUMERIC_FACTOR   |
  9464.   FLOAT
  9465. VECTOR_LITERAL:
  9466.   < FLOAT , FLOAT , FLOAT >
  9467. VECTOR_FUNCTION:
  9468.   vaxis_rotate( VECTOR , VECTOR , FLOAT )   |
  9469.   vcross( VECTOR , VECTOR )   |
  9470.   vrotate( VECTOR , VECTOR )   |
  9471.   vnormalize( VECTOR )
  9472. VECTOR_BUILT-IN_IDENT:
  9473.   x   |   y   |   z   |   t   |   u   |   v
  9474. Note: VECTOR_IDENTIFIERS are identifiers previously declared to
  9475. have vector values.
  9476.  
  9477.  
  9478. 4.1.4.1   Vector Literals
  9479. Vectors literals consist of two to five float expressions that
  9480. are bracketed by angle brackets < and >. The terms are separated
  9481. by commas. For example here is a typical three component vector:
  9482.  
  9483.  < 1.0, 3.2, -5.4578 >
  9484. The commas between components are necessary to keep the program
  9485. from thinking that the 2nd term is the single float expression
  9486. 3.2-5.4578 and that there is no 3rd term. If you see an error
  9487. message such as "Float expected but '>' found instead" then you
  9488. probably have missed a comma.
  9489.  
  9490. Sometimes POV-Ray requires you to specify floats and vectors side-
  9491. by-side. The rules for vector expressions allow for mixing of
  9492. vectors with vectors or vectors with floats so commas are
  9493. required separators whenever an ambiguity might arise. For
  9494. example <1,2,3>-4 evaluates as a mixed float and vector
  9495. expression where 4 is subtracted from each component resulting in
  9496. <-3,-2,-1>. However the comma in <1,2,3>,-4 means this is a
  9497. vector followed by a float.
  9498.  
  9499. Each component may be a full float expression. For example
  9500. <This+3,That/3,5*Other_Thing> is a valid vector.
  9501.  
  9502.  
  9503. 4.1.4.2   Vector Identifiers
  9504. Vector identifiers may be declared to make scene files more
  9505. readable and to parameterize scenes so that changing a single
  9506. declaration changes many values. An identifier is declared as
  9507. follows.
  9508.  
  9509. VECTOR_DECLARATION:
  9510.   #declare IDENTIFIER = EXPRESSION;  |
  9511.   #local IDENTIFIER = EXPRESSION;
  9512. Where IDENTIFIER is the name of the identifier up to 40
  9513. characters long and EXPRESSION is any valid expression which
  9514. evaluates to a vector value. Note that there should be a semi-
  9515. colon after the expression in a vector declaration. This semi-
  9516. colon is new with POV-Ray version 3.1. If omitted, it generates a
  9517. warning and some macros may not work properly. See "#declare vs.
  9518. #local" for information on identifier scope.  Here are some
  9519. examples....
  9520.  
  9521.  #declare Here = <1,2,3>;
  9522.  #declare There = <3,4,5>;
  9523.  #declare Jump = <Foo*2,Bar-1,Bob/3>;
  9524.  #declare Route = There-Here;
  9525.  #declare Jump = Jump+<1,2,3>;
  9526. Note that you invoke a vector identifier by using its name
  9527. without any angle brackets. As the last example shows, you can re-
  9528. declare a vector identifier and may use previously declared
  9529. values in that re-declaration. There are several built-in
  9530. identifiers which POV-Ray declares for you. See section "Built-in
  9531. Vector Identifiers" for details.
  9532.  
  9533.  
  9534. 4.1.4.3   Vector Operators
  9535. Vector literals, identifiers and functions may also be combined
  9536. in expressions the same as float values. Operations are performed
  9537. on a component-by-component basis. For example <1,2,3> + <4,5,6>
  9538. evaluates the same as <1+4,2+5,3+6> or <5,7,9>. Other operations
  9539. are done on a similar component-by-component basis. For example
  9540. (<1,2,3> = <3,2,1>) evaluates to <0,1,0> because the middle
  9541. components are equal but the others are not. Admittedly this
  9542. isn't very useful but its consistent with other vector
  9543. operations.
  9544.  
  9545. Conditional expressions such as (C ? A : B) require that C is a
  9546. float expression but A and B may be vector expressions. The
  9547. result is that the entire conditional evaluates as a valid
  9548. vector. For example if Foo and Bar are floats then (Foo < Bar ?
  9549. <1,2,3> : <5,6,7>) evaluates as the vector <1,2,3> if Foo is less
  9550. than Bar and evaluates as <5,6,7> otherwise.
  9551.  
  9552. You may use the dot operator to extract a single float component
  9553. from a vector. Suppose the identifier Spot was previously defined
  9554. as a vector. Then Spot.x is a float value that is the first
  9555. component of this x, y, z vector. Similarly Spot.y and Spot.z
  9556. reference the 2nd and 3rd components. If Spot was a two component
  9557. UV vector you could use Spot.u and Spot.v to extract the first
  9558. and second component. For a 4D vector use .x, .y, .z, and .t to
  9559. extract each float component. The dot operator is also used in
  9560. color expressions which are covered later.
  9561.  
  9562.  
  9563. 4.1.4.4   Operator Promotion
  9564. You may use a lone float expression to define a vector whose
  9565. components are all the same. POV-Ray knows when it needs a vector
  9566. of a particular type and will promote a float into a vector if
  9567. need be. For example the POV-Ray scale statement requires a three
  9568. component vector. If you specify scale 5 then POV-Ray interprets
  9569. this as scale <5,5,5> which means you want to scale by 5 in every
  9570. direction.
  9571.  
  9572. Versions of POV-Ray prior to 3.0 only allowed such use of a float
  9573. as a vector in various limited places such as scale and
  9574. turbulence. However you may now use this trick anywhere. For
  9575. example...
  9576.  
  9577.  box{0,1}  // Same as box{<0,0,0>,<1,1,1>}
  9578.  sphere{0,1} // Same as sphere{<0,0,0>,1}
  9579. When promoting a float into a vector of 2, 3, 4 or 5 components,
  9580. all components are set to the float value, however when promoting
  9581. a vector of a lower number of components into a higher order
  9582. vector, all remaining components are set to zero. For example if
  9583. POV-Ray expects a 4D vector and you specify 9 the result is
  9584. <9,9,9,9> but if you specify <7,6> the result is <7,6,0,0>.
  9585.  
  9586.  
  9587. 4.1.4.5   Built-in Vector Identifiers
  9588. There are several built-in vector identifiers. You can use them
  9589. to specify values or to create expressions but you cannot re-
  9590. declare them to change their values.  They are:
  9591.  
  9592. VECTOR_BUILT-IN_IDENT:
  9593.   x   |   y   |   z   |   t   |   u   |   v
  9594. All built-in vector identifiers never change value. They are
  9595. defined as though the following lines were at the start of every
  9596. scene.
  9597.  
  9598.  #declare x = <1, 0, 0>;
  9599.  #declare y = <0, 1, 0>;
  9600.  #declare z = <0, 0, 1>;
  9601.  #declare t = <0, 0, 0, 1>;
  9602.  #declare u = <1, 0>;
  9603.  #declare v = <0, 1>;
  9604. The built-in vector identifiers x, y, and z provide much greater
  9605. readability for your scene files when used in vector expressions.
  9606. For example....
  9607.  
  9608.  plane { y, 1}    // The normal vector is obviously "y".
  9609.  plane { <0,1,0>, 1} // This is harder to read.
  9610.  translate 5*x    // Move 5 units in the "x" direction.
  9611.  translate <5,0,0>  // This is less obvious.
  9612. An expression like 5*x evaluates to 5*<1,0,0> or <5,0,0>.
  9613.  
  9614. Similarly u and v may be used in 2D vectors. When using 4D
  9615. vectors you should use x, y, z, and t and POV-Ray will promote x,
  9616. y, and z to 4D when used where 4D is required.
  9617.  
  9618.  
  9619. 4.1.4.6   Vector Functions
  9620. POV-Ray defines a variety of built-in functions for manipulating
  9621. floats, vectors and strings. Function calls consist of a keyword
  9622. which specifies the name of the function followed by a parameter
  9623. list enclosed in parentheses. Parameters are separated by commas.
  9624. For example:
  9625.  
  9626.  keyword(param1,param2)
  9627. The following are the functions which return vector values. They
  9628. take one or more float, integer, vector, or string parameters.
  9629. Assume that A and B are any valid expression that evaluates to a
  9630. vector; and F is any float expression.
  9631.  
  9632. vaxis_rotate(A,B,F) Rotate A about B by F. Given the x,y,z
  9633. coordinates of a point in space designated by the vector A,
  9634. rotate that point about an arbitrary axis defined by the vector
  9635. B. Rotate it through an angle specified in degrees by the float
  9636. value F. The result is a vector containing the new x,y,z
  9637. coordinates of the point.
  9638.  
  9639. vcross(A,B)    Cross product of A and B. Returns a vector that is
  9640. the vector cross product of the two vectors. The resulting vector
  9641. is perpendicular to the two original vectors and its length is
  9642. proportional to the angle between them. See the animated demo
  9643. scene VECT2.POV for an illustration.
  9644.  
  9645. vnormalize(A)  Normalize vector A. Returns a unit length vector
  9646. that is the same direction as A. Formula is
  9647. vnormalize=A/vlength(A).
  9648.  
  9649. vrotate(A,B)   Rotate A about origin by B. Given the x,y,z
  9650. coordinates of a point in space designated by the vector A,
  9651. rotate that point about the origin by an amount specified by the
  9652. vector B. Rotate it about the x-axis by an angle specified in
  9653. degrees by the float value B.x. Similarly B.y and B.z specify the
  9654. amount to rotate in degrees about the y-axis and z-axis. The
  9655. result is a vector containing the new x,y,z coordinates of the
  9656. point.
  9657.  
  9658. See section "Float Functions" for other functions which are
  9659. somewhat vector-related but which return floats.  In addition to
  9660. the above built-in functions, you may also define your own
  9661. functions using the new #macro directive. See the section "User
  9662. Defined Macros" for more details.
  9663.  
  9664.  
  9665. 4.1.5     Specifying Colors
  9666. POV-Ray often requires you to specify a color. Colors consist of
  9667. five values or color components. The first three are called red,
  9668. green, and blue. They specify the intensity of the primary colors
  9669. red, green and blue using an additive color system like the one
  9670. used by the red, green and blue color phosphors on a color
  9671. monitor.
  9672.  
  9673. The 4th component, called filter, specifies the amount of
  9674. filtered transparency of a substance. Some real-world examples of
  9675. filtered transparency are stained glass windows or tinted
  9676. cellophane. The light passing through such objects is tinted by
  9677. the appropriate color as the material selectively absorbs some
  9678. frequencies of light while allowing others to pass through. The
  9679. color of the object is subtracted from the light passing through
  9680. so this is called subtractive transparency.
  9681.  
  9682. The 5th component, called transmit, specifies the amount of non-
  9683. filtered light that is transmitted through a surface. Some real-
  9684. world examples of non-filtered transparency are thin see-through
  9685. cloth, fine mesh netting and dust on a surface. In these
  9686. examples, all frequencies of light are allowed to pass through
  9687. tiny holes in the surface. Although the amount of light passing
  9688. through is diminished, the color of the light passing through is
  9689. unchanged. The color of the object is added to the light passing
  9690. through so this is called additive transparency.
  9691.  
  9692. Note that early versions of POV-Ray used the keyword alpha to
  9693. specify filtered transparency. However that word is often used to
  9694. describe non-filtered transparency. For this reason alpha is no
  9695. longer used.
  9696.  
  9697. Each of the five components of a color are float values which are
  9698. normally in the range between 0.0 and 1.0. However any values,
  9699. even negatives may be used.
  9700.  
  9701. Under most circumstances the keyword color is optional and may be
  9702. omitted. We also support the British or Canadian spelling colour.
  9703. Colors may be specified using vectors, keywords with floats or
  9704. identifiers. You may also create very complex color expressions
  9705. from combinations of any of these using various familiar
  9706. operators. The syntax for specifying a color has evolved since
  9707. POV-Ray was first released. We have maintained the original
  9708. keyword-based syntax and added a short-cut vector notation.
  9709. Either the old or new syntax is acceptable however the vector
  9710. syntax is easier to use when creating color expressions.
  9711.  
  9712. The syntax for combining color literals into color expressions is
  9713. almost identical to the rules for vector and float expressions.
  9714. In the syntax for vector expressions below, some of the syntax
  9715. items are defined in the section for float expressions.  See
  9716. "Float Expressions" for those definitions.  Detailed explanations
  9717. of color-specific issues are given in the following sub-sections.
  9718.  
  9719. COLOR:
  9720.   COLOR_BODY               |
  9721.   color COLOR_BODY         |    (this means the keyword color or
  9722.   colour may
  9723.   colour COLOR_BODY               optionally precede any color
  9724.   specification)
  9725. COLOR_BODY:
  9726.   COLOR_VECTOR             |
  9727.   COLOR_KEYWORD_GROUP      |
  9728.   COLOR_IDENTIFIER
  9729. COLOR_VECTOR:
  9730.   rgb <3_Term_Vector>      |
  9731.   rgbf <4_Term_Vector>          |
  9732.   rgbt <4_Term_Vector>          |
  9733.   [ rgbft ] <5_Term_Vector>
  9734. COLOR_KEYWORD_GROUP:
  9735.   [ COLOR_KEYWORD_ITEM ]...
  9736. COLOR_KEYWORD_ITEM:
  9737.   COLOR_IDENTIFIER         |
  9738.   red Red_Amount   |   blue Blue_Amount   |   green Green_Amount
  9739.   |
  9740.   filter Filter_Amount   |   transmit Transmit_Amount
  9741. Note: COLOR_IDENTIFIERS are identifiers previously declared to
  9742. have color values.  The 3, 4, and 5 term vectors are usually
  9743. vector literals but may be vector expressions or floats promoted
  9744. to vectors.  See "Operator Promotion" and the sections below.
  9745.  
  9746.  
  9747. 4.1.5.1   Color Vectors
  9748. The syntax for a color vector is...
  9749.  
  9750. COLOR_VECTOR:
  9751.   rgb <3_Term_Vector>      |
  9752.   rgbf <4_Term_Vector>          |
  9753.   rgbt <4_Term_Vector>          |
  9754.   [ rgbft ] <5_Term_Vector>
  9755. ...where the vectors are any valid vector expressions of 3, 4 or
  9756. 5 components. For example
  9757.  
  9758.  color rgb <1.0, 0.5, 0.2>
  9759. This specifies a color whose red component is 1.0 or 100% of full
  9760. intensity. The green component is 0.5 or 50% of full intensity
  9761. and the blue component is 0.2 or 20% of full intensity. Although
  9762. the filter and transmit components are not explicitly specified,
  9763. they exist and are set to their default values of 0 or no
  9764. transparency.
  9765.  
  9766. The rgbf keyword requires a four component vector. The 4th
  9767. component is the filter component and the transmit component
  9768. defaults to zero. Similarly the rgbt keyword requires four
  9769. components where the 4th value is moved to the 5th component
  9770. which is transmit and then the filter component is set to zero.
  9771.  
  9772. The rgbft keyword allows you to specify all five components.
  9773. Internally in expressions all five are always used.
  9774.  
  9775. Under some circumstances, if the vector expression is a 5
  9776. component expression or there is a color identifier in the
  9777. expression then the rgbtf keyword is optional.
  9778.  
  9779.  
  9780. 4.1.5.2   Color Keywords
  9781. The older keyword method of specifying a color is still useful
  9782. and many users prefer it.
  9783.  
  9784. COLOR_KEYWORD_GROUP:
  9785.   [ COLOR_KEYWORD_ITEM ]...
  9786. COLOR_KEYWORD_ITEM:
  9787.   COLOR_IDENTIFIER         |
  9788.   red Red_Amount   |   blue Blue_Amount   |   green Green_Amount
  9789.   |
  9790.   filter Filter_Amount   |   transmit Transmit_Amount
  9791. Although the color keyword at the beginning is optional, it is
  9792. more common to see it in this usage. This is followed by any of
  9793. five additional keywords red, green, blue, filter, or transmit.
  9794. Each of these component keywords is followed by a float
  9795. expression. For example
  9796.  
  9797.  color red 1.0 green 0.5
  9798. This specifies a color whose red component is 1.0 or 100% of full
  9799. intensity and the green component is 0.5 or 50% of full
  9800. intensity. Although the blue, filter and transmit components are
  9801. not explicitly specified, they exist and are set to their default
  9802. values of 0. The component keywords may be given in any order and
  9803. if any component is unspecified its value defaults to zero.  A
  9804. COLOR_IDENTIFIER can also be specified but it should always be
  9805. first in the group.  See "Common Color Pitfalls" for details.
  9806.  
  9807.  
  9808. 4.1.5.3   Color Identifiers
  9809. Color identifiers may be declared to make scene files more
  9810. readable and to parameterize scenes so that changing a single
  9811. declaration changes many values. An identifier is declared as
  9812. follows.
  9813.  
  9814. COLOR_DECLARATION:
  9815.   #declare IDENTIFIER = COLOR;  |
  9816.   #local IDENTIFIER = COLOR;
  9817. Where IDENTIFIER is the name of the identifier up to 40
  9818. characters long and COLOR is any valid specification. Note that
  9819. there should be a semi-colon at the end of the declaration. This
  9820. semi-colon is new with POV-Ray version 3.1. If omitted, it
  9821. generates a warning and some macros may not work properly. See
  9822. "#declare vs. #local" for information on identifier scope.  Here
  9823. are some examples....
  9824.  
  9825.  #declare White = rgb <1,1,1>;
  9826.  #declare Cyan = color blue 1.0 green 1.0;
  9827.  #declare Weird = rgb <Foo*2,Bar-1,Bob/3>;
  9828.  #declare LightGray = White*0.8;
  9829.  #declare LightCyan = Cyan red 0.6;
  9830. As the LightGray example shows you do not need any color keywords
  9831. when creating color expressions based on previously declared
  9832. colors. The last example shows you may use a color identifier
  9833. with the keyword style syntax. Make sure that the identifier
  9834. comes first before any other component keywords.
  9835.  
  9836. Like floats and vectors, you may re-define colors throughout a
  9837. scene but the need to do so is rare.
  9838.  
  9839.  
  9840. 4.1.5.4   Color Operators
  9841. Color vectors may be combined in expressions the same as float or
  9842. vector values. Operations are performed on a component-by-
  9843. component basis. For example rgb <1.0,0.5,0.2>*0.9 evaluates the
  9844. same as rgb<1.0,0.5,0.2>*<0.9,0.9,0.9> or rgb<0.9,0.45,0.18>.
  9845. Other operations are done on a similar component-by-component
  9846. basis.
  9847.  
  9848. You may use the dot operator to extract a single component from a
  9849. color. Suppose the identifier Shade was previously defined as a
  9850. color. Then Shade.red is the float value of the red component of
  9851. Shade. Similarly Shade.green, Shade.blue, Shade.filter and
  9852. Shade.transmit extract the float value of the other color
  9853. components.
  9854.  
  9855.  
  9856. 4.1.5.5   Common Color Pitfalls
  9857. The variety and complexity of color specification methods can
  9858. lead to some common mistakes. Here are some things to consider
  9859. when specifying a color.
  9860.  
  9861. When using filter transparency, the colors which come through are
  9862. multiplied by the primary color components. For example if gray
  9863. light such as rgb<0.9,0.9,0.9> passes through a filter such as
  9864. rgbf<1.0,0.5,0.0,1.0> the result is rgb<0.9,0.45,0.0> with the
  9865. red let through 100%, the green cut in half from 0.9 to 0.45 and
  9866. the blue totally blocked. Often users mistakenly specify a clear
  9867. object by
  9868.  
  9869.  color filter 1.0
  9870. but this has implied red, green and blue values of zero. You've
  9871. just specified a totally black filter so no light passes through.
  9872. The correct way is either
  9873.  
  9874.  color red 1.0  green 1.0  blue 1.0  filter 1.0
  9875. or
  9876.  
  9877.  color transmit 1.0
  9878. In the 2nd example it doesn't matter what the rgb values are. All
  9879. of the light passes through untouched.
  9880.  
  9881. Another pitfall is the use of color identifiers and expressions
  9882. with color keywords. For example...
  9883.  
  9884.  color My_Color red 0.5
  9885. this substitutes whatever was the red component of My_Color with
  9886. a red component of 0.5 however...
  9887.  
  9888.  color My_Color + red 0.5
  9889. adds 0.5 to the red component of My_Color and even less
  9890. obvious...
  9891.  
  9892.  color My_Color * red 0.5
  9893. that cuts the red component in half as you would expect but it
  9894. also multiplies the green, blue, filter and transmit components
  9895. by zero! The part of the expression after the multiply operator
  9896. evaluates to rgbft<0.5,0,0,0,0> as a full 5 component color.
  9897.  
  9898. The following example results in no change to My_Color.
  9899.  
  9900.  color red 0.5 My_Color
  9901. This is because the identifier fully overwrites the previous
  9902. value. When using identifiers with color keywords, the identifier
  9903. should be first.
  9904.  
  9905. Another issue to consider: some POV-Ray syntax allows full color
  9906. specifications but only uses the rgb part. In these cases it is
  9907. legal to use a float where a color is needed. For example:
  9908.  
  9909.  finish { ambient 1 }
  9910. The ambient keyword expects a color so the value 1 is promoted to
  9911. <1,1,1,1,1> which is no problem. However
  9912.  
  9913.  pigment { color 0.4 }
  9914. is legal but it may or may not be what you intended. The 0.4 is
  9915. promoted to <0.4,0.4,0.4,0.4,0.4> with the filter and transmit
  9916. set to 0.4 as well. It is more likely you wanted...
  9917.  
  9918.  pigment { color rgb 0.4 }
  9919. in which case a 3 component vector is expected. Therefore the 0.4
  9920. is promoted to <0.4,0.4,0.4,0.0,0.0> with default zero for filter
  9921. and transmit.
  9922.  
  9923. Finally there is another problem which arises when using color
  9924. dot operators in #declare or #local directives.  Consider the
  9925. directive:
  9926.  
  9927.  #declare MyColor = rgb <0.75, 0.5, 0.75>;
  9928.  #declare RedAmt = MyColor.red;
  9929. Now RedAmt should be a float but unfortunately it is a color.
  9930. POV-Ray looks at the first keyword after the equals to try to
  9931. guess what type of identifier you want.  It sees the color
  9932. identifier MyColor and assumes you want to declare a color.  It
  9933. then computes the float value as 0.75 then promotes that into
  9934. rgbft<0.75,0.75,0.75,0.75,0.75>.
  9935.  
  9936. It would take a major rewrite to fix this problem so we're just
  9937. warning you about it.  Any of the following work-arounds will
  9938. work properly.
  9939.  
  9940.  #declare RedAmt = 0.0+MyColor.red;
  9941.  #declare RedAmt = 1.0*MyColor.red;
  9942.  #declare RedAmt = (MyColor.red);
  9943.  
  9944. 4.1.6     Strings
  9945. The POV-Ray language requires you to specify a string of
  9946. characters to be used as a file name, text for messages or text
  9947. for a text object. Strings may be specified using literals,
  9948. identifiers or functions which return string values. See "String
  9949. Functions" for details on string functions.  Although you cannot
  9950. build string expressions from symbolic operators such as are used
  9951. with floats, vectors or colors, you may perform various string
  9952. operations using string functions. Some applications of strings
  9953. in POV-Ray allow for non-printing formatting characters such as
  9954. newline or form-feed.
  9955.  
  9956. STRING:
  9957.   STRING_FUNCTION          |
  9958.   STRING_IDENTIFIER   |
  9959.   STRING_LITERAL
  9960. STRING_LITERAL:
  9961.   "up to 256 ASCII characters"
  9962. STRING_FUNCTION:
  9963.   str( FLOAT , INT , INT )   |   concat( STRING , STRING ,
  9964.   [STRING ,...])   |   chr( INT )   |
  9965.   substr( STRING , INT , INT )   |   strupr( STRING )   |
  9966.   strlwr( STRING )
  9967.  
  9968. 4.1.6.1   String Literals
  9969. String literals begin with a double quote mark '"' which is
  9970. followed by up to 256 printable ASCII characters and are
  9971. terminated by another double quote mark. The following are all
  9972. valid string literals:
  9973.  
  9974.  "Here"  "There"  "myfile.gif"  "textures.inc"
  9975. Note if you need to specify a quote mark in a string literal you
  9976. must precede it with a backslash. For example
  9977.  
  9978.  "Joe said \"Hello\" as he walked in."
  9979. is converted to
  9980.  
  9981.  Joe said "Hello" as he walked in.
  9982. If you need to specify a backslash, most of the time you need do
  9983. nothing special. However if the string ends in a backslash, you
  9984. will have to specify two. For example:
  9985.  
  9986.  "This is a backslash \ and so is this\\"
  9987. Is converted to:
  9988.  
  9989.  This is a backslash \ and so is this\
  9990. The substitution of \" with a " occurs in all POV-Ray string
  9991. literals regardless usage however other formatting codes such as
  9992. \n for new line are only supported in user message streams. See
  9993. "Text Formatting" for details.
  9994.  
  9995.  
  9996. 4.1.6.2   String Identifiers
  9997. String identifiers may be declared to make scene files more
  9998. readable and to parameterize scenes so that changing a single
  9999. declaration changes many values. An identifier is declared as
  10000. follows.
  10001.  
  10002. STRING_DECLARATION:
  10003.   #declare IDENTIFIER = STRING  |
  10004.   #local IDENTIFIER = STRING
  10005. Where IDENTIFIER is the name of the identifier up to 40
  10006. characters long and STRING is any valid string specification.
  10007. Note that unlike floats, vectors, or colors, there need not be a
  10008. semi-colon at the end of the declaration. See "#declare vs.
  10009. #local" for information on identifier scope.  Here are some
  10010. examples...
  10011.  
  10012.  #declare Font_Name = "ariel.ttf"
  10013.  #declare Inc_File = "myfile.inc"
  10014.  #declare Name = "John"
  10015.  #declare Name = concat(Name," Doe")
  10016. As the last example shows, you can re-declare a string identifier
  10017. and may use previously declared values in that re-declaration.
  10018.  
  10019.  
  10020. 4.1.6.3   String Functions
  10021. POV-Ray defines a variety of built-in functions for manipulating
  10022. floats, vectors and strings. Function calls consist of a keyword
  10023. which specifies the name of the function followed by a parameter
  10024. list enclosed in parentheses. Parameters are separated by commas.
  10025. For example:
  10026.  
  10027.  keyword(param1,param2)
  10028. The following are the functions which return string values. They
  10029. take one or more float, integer, vector, or string parameters.
  10030. Assume that A is any valid expression that evaluates to a float;
  10031. B, L, and P are floats which are truncated to integers
  10032. internally, S, S1, S2 etc are strings.
  10033.  
  10034. chr(B)    Character whose ASCII value is B. Returns a single
  10035. character string. The ASCII value of the character is specified
  10036. by an integer B which must be in the range 0 to 255. For example
  10037. chr(70) is the string "F". When rendering text objects you should
  10038. be aware that the characters rendered for values of B > 127 are
  10039. dependent on the (TTF) font being used. Many (TTF) fonts use the
  10040. Latin-1 (ISO 8859-1) character set, but not all do.
  10041.  
  10042. concat(S1,S2,...)   Concatenate strings S1 and S2. Returns a
  10043. string that is the concatenation of all parameter strings. Must
  10044. have at least 2 parameters but may have more. For example:
  10045.  
  10046.  concat("Value is ", str(A,3,1), " inches")
  10047. If the float value A was 12.34321 the result is "Value is 12.3
  10048. inches" which is a string.
  10049.  
  10050. str(A,L,P): Convert float A to a formatted string. Returns a
  10051. formatted string representation of float value A. The integer
  10052. parameter L specifies the minimum length of the string and the
  10053. type of left padding used if the string's representation is
  10054. shorter than the minimum. If L is positive then the padding is
  10055. with blanks. If L is negative then the padding is with zeros. The
  10056. overall minimum length of the formatted string is abs(L). If the
  10057. string needs to be longer, it will be made as long as necessary
  10058. to represent the value.
  10059.  
  10060. The integer parameter P specifies the number of digits after the
  10061. decimal point. If P is negative then a compiler-specific default
  10062. precision is use. Here are some examples:
  10063.  
  10064.  str(123.456,0,3)  "123.456"
  10065.  str(123.456,4,3)  "123.456"
  10066.  str(123.456,9,3)  "  123.456"
  10067.  str(123.456,-9,3) "00123.456"
  10068.  str(123.456,0,2)  "123.46"
  10069.  str(123.456,0,0)  "123"
  10070.  str(123.456,5,0)  "  123"
  10071.  str(123.000,7,2)  "  123.00"
  10072.  str(123.456,0,-1) "123.456000" (platform specific)
  10073. strlwr(S) Lower case of S. Returns a new string in which all
  10074. upper case letters in the string S1 are converted to lower case.
  10075. The original string is not affected. For example strlwr("Hello
  10076. There!") results in "hello there!".
  10077.  
  10078. substr(S,P,L)  Sub-string from S. Returns a string that is a
  10079. subset of the characters in parameter S starting at the position
  10080. specified by the integer value P for a length specified by the
  10081. integer value L. For example substr("ABCDEFGHI",4,2) evaluates to
  10082. the string "EF". If P+L>strlen(S) an error occurs.
  10083.  
  10084. strupr(S) Upper case of S. Returns a new string in which all
  10085. lower case letters in the string S are converted to upper case.
  10086. The original string is not affected. For example strupr("Hello
  10087. There!") results in "HELLO THERE!".
  10088.  
  10089. See section "Float Functions" for other functions which are
  10090. somewhat string-related but which return floats.  In addition to
  10091. the above built-in functions, you may also define your own
  10092. functions using the new #macro directive. See the section "User
  10093. Defined Macros" for more details.
  10094.  
  10095.  
  10096. 4.1.7     Array Identifiers
  10097. New in POV-Ray 3.1 you may now declare arrays of identifiers of
  10098. up to five dimensions. Any item that can be declared as an
  10099. identifier can be declared in an array.
  10100.  
  10101.  
  10102. 4.1.7.1   Declaring Arrays
  10103. The syntax for declaring an array is as follows:
  10104.  
  10105. STRING_DECLARATION:
  10106.   #declare IDENTIFIER = array[ INT ][ [ INT ]
  10107.   ]...[ARRAY_INITIALIZER]  |
  10108.   #local IDENTIFIER = array[ INT ][ [ INT ]
  10109.   ]...[ARRAY_INITIALIZER]
  10110. ARRAY_INITIALIZER:
  10111.   {ARRAY_ITEM, [ARRAY_ITEM, ]... }
  10112. ARRAY_ITEM:
  10113.   RVALUE              |
  10114.   ARRAY_INITIALIZER
  10115. Where IDENTIFIER is the name of the identifier up to 40
  10116. characters long and INT is a valid float expression which is
  10117. internally truncated to an integer which specifies the size of
  10118. the array. The optional ARRAY_INITIALIZER is discussed in the
  10119. next section "Array Initalizers".  Here is an example of a one-
  10120. dimensional, uninitalized array.
  10121.  
  10122.  #declare MyArray = array[10]
  10123. This declares an uninitalized array of ten elements. The elements
  10124. are referenced as MyArray[0] through MyArray[9]. As yet, the type
  10125. of the elements are undetermined. Once you have initialized any
  10126. element of the array, all other elements can only be defined as
  10127. that type. An attempt to reference an uninitalized element
  10128. results in an error. For example:
  10129.  
  10130.  #declare MyArray = array[10];
  10131.  #declare MyArray[5] = pigment{White}  //all other elements must
  10132. be
  10133.                      //pigments too.
  10134.  #declare MyArray[2] = normal{bumps 0.2} //generates an error
  10135.  #declare Thing = MyArray[4] //error: uninitalized array element
  10136. Multi-dimensional arrays up to five dimensions may be declared.
  10137. For example:
  10138.  
  10139.  #declare MyGrid = array[4][5]
  10140. declares a 20 element array of 4 rows and 5 columns. Elements are
  10141. referenced from MyGrid[0][0] to MyGrid[3][4]. Although it is
  10142. permissible to reference an entire array as a whole, you may not
  10143. reference just one dimension of a multi-dimensional array. For
  10144. example:
  10145.  
  10146.  #declare MyArray = array[10]
  10147.  #declare MyGrid = array[4][5]
  10148.  #declare YourArray = MyArray  //this is ok
  10149.  #declare YourGrid = MyGrid   //so is this
  10150.  #declare OneRow  = MyGrid[2] //this is illegal
  10151. Large uninitalized arrays do not take much memory. Internally
  10152. they are arrays of pointers so they probably use just 4 bytes per
  10153. element. Once initialized with values, they consume memory
  10154. depending on what you put in them.
  10155.  
  10156. The rules for local vs. global arrays are the same as any other
  10157. identifier. Note that this applies to the entire array. You
  10158. cannot mix local and global elements in the same array.  See
  10159. "#declare vs. #local" for information on identifier scope.
  10160.  
  10161.  
  10162. 4.1.7.2   Array Initalizers
  10163. Because it is cumbersome to individually initialize the elements
  10164. of an array, you may initialize it as it is created using array
  10165. initializer syntax. For example:
  10166.  
  10167.  #include "colors.inc"
  10168.  #declare FlagColors = array[3] {Red,White,Blue}
  10169. Multi-dimensional arrays may also be initialized this way. For
  10170. example:
  10171.  
  10172.  #declare Digits =
  10173.  array[4][10]
  10174.  {
  10175.   {7,6,7,0,2,1,6,5,5,0},
  10176.   {1,2,3,4,5,6,7,8,9,0},
  10177.   {0,9,8,7,6,5,4,3,2,1},
  10178.   {1,1,2,2,3,3,4,4,5,5}
  10179.  }
  10180. The commas are required between elements and between dimensions
  10181. as shown in the example.
  10182.  
  10183.  
  10184. 4.2  Language Directives
  10185. The POV Scene Language contains several statements called
  10186. language directives which tell the file parser how to do its job.
  10187. These directives can appear in almost any place in the scene file
  10188. - even in the middle of some other statements. They are used to
  10189. include other text files in the stream of commands, to declare
  10190. identifiers, to define macros, conditional, or looped parsing and
  10191. to control other important aspects of scene file processing.
  10192.  
  10193. Each directive begins with the hash character # (often called a
  10194. number sign or pound sign). It is followed by a keyword and
  10195. optionally other parameters.
  10196.  
  10197. In versions of POV-Ray prior to 3.0, the use of this # character
  10198. was optional. Language directives could only be used between
  10199. objects, camera or light_source statements and could not appear
  10200. within those statements. The exception was the #include which
  10201. could appear anywhere. Now that all language directives can be
  10202. used almost anywhere, the # character is mandatory.
  10203.  
  10204. The following keywords introduce language directives.
  10205.  
  10206. #break      #case        #debug      #declare
  10207. #default    #else        #end        #fclose
  10208. #fopen      #local       #macro      #read
  10209. #render     #statistics  #switch     #undef
  10210. #version    #warning     #write      
  10211. Earlier versions of POV-Ray considered the keyword
  10212. #max_intersections and the keyword #max_trace_level to be
  10213. language directives but they have been moved to the
  10214. global_settings statement and should be placed there without the
  10215. # sign. Their use as a directive still works but it generates a
  10216. warning and may be discontinued in the future.
  10217.  
  10218.  
  10219. 4.2.1     Include Files and the #include Directive.
  10220. The language allows include files to be specified by placing the
  10221. line
  10222.  
  10223.  #include "filename.inc"
  10224. at any point in the input file. The filename may be specified by
  10225. any valid string expression but it usually is a literal string
  10226. enclosed in double quotes. It may be up to 40 characters long (or
  10227. your computer's limit), including the two double-quote
  10228. characters.
  10229.  
  10230. The include file is read in as if it were inserted at that point
  10231. in the file. Using include is almost the same as cutting and
  10232. pasting the entire contents of this file into your scene.
  10233.  
  10234. Include files may be nested. You may have at most 10 nested
  10235. include files. There is no limit on un-nested include files.
  10236.  
  10237. Generally, include files have data for scenes but are not scenes
  10238. in themselves. By convention scene files end in .pov and include
  10239. files end with .inc.
  10240.  
  10241. It is legal to specify drive and directory information in the
  10242. file specification however it is discouraged because it makes
  10243. scene files less portable between various platforms.  Use of full
  10244. lower case is also recommended but not required.
  10245.  
  10246. It is typical to put standard include files in a special sub-
  10247. directory. POV-Ray can only read files in the current directory
  10248. or one referenced by the Library_Path option or +L switch.  See
  10249. section "Library Paths".
  10250.  
  10251. You may use the #local directive to declare identifiers which are
  10252. temporary in duration and local to the include file in scope. For
  10253. details see "#declare vs. #local".
  10254.  
  10255.  
  10256. 4.2.2     The #declare and #local Directives
  10257. Identifiers may be declared and later referenced to make scene
  10258. files more readable and to parameterize scenes so that changing a
  10259. single declaration changes many values. There are several built-
  10260. in identifiers which POV-Ray declares for you. See section "Built-
  10261. in Float Identifiers" and "Built-in Vector Identifiers" for
  10262. details.
  10263.  
  10264.  
  10265. 4.2.2.1   Declaring identifiers
  10266. An identifier is declared as follows.
  10267.  
  10268. DECLARATION:
  10269.   #declare IDENTIFIER = RVALUE  |
  10270.   #local IDENTIFIER = RVALUE
  10271. RVALUE:
  10272.   FLOAT;   |   VECTOR;   |   COLOR;   |   STRING   |
  10273.   OBJECT   |   TEXTURE   |   PIGMENT   |   NORMAL   |   FINISH
  10274.   |
  10275.   INTERIOR   |   MEDIA   |   DENSITY
  10276.   COLOR_MAP   |   PIGMENT_MAP   |   SLOPE_MAP   |   NORMAL_MAP
  10277.   |   DENSITY_MAP   |
  10278.   CAMERA   |   LIGHT_SOURCE   |
  10279.   FOG   |    RAINBOW   |    SKY_SPHERE   |    TRANSFORM
  10280. Where IDENTIFIER is the name of the identifier up to 40
  10281. characters long and RVALUE is any of the listed items.  They are
  10282. called that because they are values that can appear to the right
  10283. of the equals sign.  The syntax for each is in the corresponding
  10284. section of this language reference.
  10285.  
  10286. Here are some examples.
  10287.  
  10288.  #declare Rows = 5;
  10289.  #declare Count = Count+1;
  10290.  #local  Here = <1,2,3>;
  10291.  #declare White = rgb <1,1,1>;
  10292.  #declare Cyan = color blue 1.0 green 1.0;
  10293.  #declare Font_Name = "ariel.ttf"
  10294.  #declare Rod = cylinder {-5*x,5*x,1}
  10295.  #declare Ring = torus {5,1}
  10296.  #local  Checks = pigment { checker White, Cyan }
  10297.  object{ Rod scale y*5 }     // not "cylinder { Rod }"
  10298.  object {
  10299.   Ring
  10300.   pigment { Checks scale 0.5 }
  10301.   transform Skew
  10302.  }
  10303. Note that there should be a semi-colon after the expression in
  10304. all float, vector and color identifier declarations. This semi-
  10305. colon is new with POV-Ray version 3.1. If omitted, it generates a
  10306. warning and some macros may not work properly.
  10307.  
  10308. Declarations, like most language directives, can appear anywhere
  10309. in the file - even within other statements. For example:
  10310.  
  10311.  #declare Here=<1,2,3>;
  10312.  #declare Count=0;         // initialize Count
  10313.  union {
  10314.   object { Rod translate Here*Count }
  10315.   #declare Count=Count+1;     // re-declare inside union
  10316.   object { Rod translate Here*Count }
  10317.   #declare Count=Count+1;     // re-declare inside union
  10318.   object { Rod translate Here*Count }
  10319.  }
  10320. As this example shows, you can re-declare an identifier and may
  10321. use previously declared values in that re-declaration. However if
  10322. you attempt to re-declare an identifier as anything other than
  10323. its original type, it will generate a warning message.
  10324.  
  10325. Note that object identifiers use the generic wrapper statement
  10326. object{ ... }. You do not need to know what kind of object it is.
  10327.  
  10328. Declarations may be nested inside each other within limits. In
  10329. the example in the previous section you could declare the entire
  10330. union as a object. However for technical reasons there are
  10331. instances where you may not use any language directive inside the
  10332. declaration of floats, vectors or color expressions. Although
  10333. these limits have been loosened somewhat for POV-Ray 3.1, they
  10334. still exist.
  10335.  
  10336. Identifiers declared within #macro ... #end blocks are not
  10337. created at the time the macro is defined. They are only created
  10338. at the time the macro is actually invoked. Like all other items
  10339. inside such a #macro definition, they are ignored when the macro
  10340. is defined.
  10341.  
  10342.  
  10343. 4.2.2.2   #declare vs. #local
  10344. Identifiers may be declared either global using #declare or local
  10345. using the #local directive.
  10346.  
  10347. Those created by the #declare directive are permanent in duration
  10348. and global in scope. Once created, they are available throughout
  10349. the scene and they are not released until all parsing is complete
  10350. or until they are specifically released using #undef. See
  10351. "Destroying Identifiers".
  10352.  
  10353. Those created by the #local directive are temporary in duration
  10354. and local in scope. They temporarily override any identifiers
  10355. with the same name. See "Identifier Name ".
  10356.  
  10357. If #local is used inside a #macro then the identifier is local to
  10358. that macro. When the macro is invoked and the #local directive is
  10359. parsed, the identifier is created. It persists until the #end
  10360. directive of the macro is reached. At the #end directive, the
  10361. identifier is destroyed. Subsequent invocations of the macro
  10362. create totally new identifiers.
  10363.  
  10364. Use of #local within an include file but not in a macro, also
  10365. creates a temporary identifier that is local to that include
  10366. file. When the include file is included and the #local directive
  10367. is parsed, the identifier is created. It persists until the end
  10368. of the include file is reached. At the end of file the identifier
  10369. is destroyed. Subsequent inclusions of the file totally new
  10370. identifiers.
  10371.  
  10372. Use of #local in the main scene file (not in an include file and
  10373. not in a macro) is identical to #declare. For clarity sake you
  10374. should not use #local in a main file except in a macro.
  10375.  
  10376. There is currently no way to create permanent, yet local
  10377. identifiers in POV-Ray.
  10378.  
  10379. Local identifiers may be specifically released early using #undef
  10380. but in general there is no need to do so. See "Destroying
  10381. Identifiers".
  10382.  
  10383.  
  10384. 4.2.2.3   Identifier Name Collisions
  10385. Local identifiers may have the same names as previously declared
  10386. identifiers. In this instance, the most recent, most local
  10387. identifier takes precedence. Upon entering an include file or
  10388. invoking a macro, a new symbol table is created. When referencing
  10389. identifiers, the most recently created symbol table is searched
  10390. first, then the next most recent and so on back to the global
  10391. table of the main scene file. As each macro or include file is
  10392. exited, its table and identifiers are destroyed. Parameters
  10393. passed by value reside in the same symbol table as the one used
  10394. for identifiers local to the macro.
  10395.  
  10396. The rules for duplicate identifiers may seem complicated when
  10397. multiply-nested includes and macros are involved, but in actual
  10398. practice the results are generally what you intended.
  10399.  
  10400. Consider this example: You have a main scene file called
  10401. myscene.pov and it contains
  10402.  
  10403.  #declare A = 123;
  10404.  #declare B = rgb<1,2,3>;
  10405.  #declare C = 0;
  10406.  #include "myinc.inc"
  10407. Inside the include file you invoke a macro called MyMacro(J,K,L).
  10408. Note it isn't important where MyMacro is defined as long as it is
  10409. defined before it is invoked. In this example, it is important
  10410. that the macro is invoked from within myinc.inc.
  10411.  
  10412. The identifiers A, B, and C are generally available at all
  10413. levels. If either myinc.inc or MyMacro contain a line such as
  10414. #declare C=C+1; then the value C is changed everywhere as you
  10415. might expect.
  10416.  
  10417. Now suppose inside myinc.inc you do...
  10418.  
  10419.  #local A = 546;
  10420. The main version of A is hidden and a new A is created. This new
  10421. A is also available inside MyMacro because MyMacro is nested
  10422. inside myinc.inc. Once you exit myinc.inc, the local A is
  10423. destroyed and the original A with its value of 123 is now in
  10424. effect. Once you have created the local A inside myinc.inc, there
  10425. is no way to reference the original global A unless you #undef A
  10426. or exit the include file. Using #undef always undefines the most
  10427. local version of an identifier.
  10428.  
  10429. Similarly if MyMacro contained...
  10430.  
  10431.  #local B = box{0,1}
  10432. then a new identifier B is created local to the macro only. The
  10433. original value of B remains hidden but is restored when the macro
  10434. is finished. Note that the local B need not have the same type as
  10435. the original.
  10436.  
  10437. The complication comes when trying to assign a new value to an
  10438. identifier at one level that was declared local at an earlier
  10439. level. Suppose inside myinc.inc you do...
  10440.  
  10441.  #local D = 789;
  10442. If you are inside myinc.inc and you want to increment D by one,
  10443. you might try to do...
  10444.  
  10445.  #local D = D + 1;
  10446. but if you try to do that inside MyMacro you'll create a new D
  10447. which is local to MyMacro and not the D which is external to
  10448. MyMacro but local to myinc.inc. Therefore you've said "create a
  10449. MyMacro D from the value of myinc.inc's D plus one". That's
  10450. probably not what you wanted. Instead you should do...
  10451.  
  10452.  #declare D = D + 1;
  10453. You might think this creates a new D that is global but it
  10454. actually increments the myinc.inc version of D. Confusing isn't
  10455. it? Here are the rules:
  10456.  
  10457. 1.) When referencing an identifier, you always get the most
  10458. recent, most local version. By "referencing" we mean using the
  10459. value of the identifier in a POV-Ray statement or using it on the
  10460. right of an equals sign in either a #declare or #local.
  10461.  
  10462. 2.) When declaring an identifier using the #local keyword, the
  10463. identifier which is created or has a new value assigned, is
  10464. ALWAYS created at the current nesting level of macros or include
  10465. files.
  10466.  
  10467. 3.) When declaring a NEW, NON-EXISTANT identifier using #declare,
  10468. it is created as fully global. It is put in the symbol table of
  10469. the main scene file.
  10470.  
  10471. 4.) When ASSIGNING A VALUE TO AN EXISTING identifier using
  10472. #declare, it assigns it to the most recent, most local version at
  10473. the time.
  10474.  
  10475. In summary, #local always means "the current level", and #declare
  10476. means "global" for new identifiers and "most recent" for existing
  10477. identifiers.
  10478.  
  10479.  
  10480. 4.2.2.4   Destroying Identifiers with #undef
  10481. Identifiers created with #declare will generally persist until
  10482. parsing is complete. Identifiers created with #local will persist
  10483. until the end of the macro or include file in which they were
  10484. created. You may however un-define an identifier using the #undef
  10485. directive. For example:
  10486.  
  10487.  #undef MyValue
  10488. If multiple local nested versions of the identifier exist, the
  10489. most local most recent version is deleted and any identically
  10490. named identifiers which were created at higher levels will still
  10491. exist.
  10492.  
  10493. See also "The #ifdef and #ifndef Directives".
  10494.  
  10495.  
  10496. 4.2.3     File I/O Directives
  10497. New in POV-Ray 3.1 you may now open, read, write, append, and
  10498. close plain ASCII text files while parsing POV-Ray scenes. This
  10499. feature is primarily intended to help pass information between
  10500. frames of an animation. Values such as an object's position can
  10501. be written while parsing the current frame and read back during
  10502. the next frame. Clever use of this feature could allow a POV-Ray
  10503. scene to generate its own include files or write self-modifying
  10504. scripts. We trust that users will come up with other interesting
  10505. uses for this feature.
  10506.  
  10507.  
  10508. 4.2.3.1   The #fopen Directive
  10509. Users may open a text file using the #fopen directive. The syntax
  10510. is as follows:
  10511.  
  10512. FOPEN_DIRECTIVE:
  10513.   #fopen IDENTIFIER "filename" OPEN_TYPE
  10514. OPEN_TYPE:
  10515.   read   |   write   |   append
  10516. Where IDENTIFIER is an undefined identifier used to reference
  10517. this file as a file handle, "filename" is any string literal or
  10518. string expression which specifies the file name.  Files opened
  10519. with the read are open for read only. Those opened with write
  10520. create a new file with the specified name and it overwrites any
  10521. existing file with that name. Those opened with append opens a
  10522. file for writing but appends the text to the end of any existing
  10523. file.
  10524.  
  10525. The file handle identifier created by #fopen is always global and
  10526. remains in effect (and the file remains open) until the scene
  10527. parsing is complete or until you #fclose the file. You may use
  10528. #ifdef FILE_HANDLE_IDENTIFIER to see if a file is open.
  10529.  
  10530.  
  10531. 4.2.3.2   The #fclose Directive
  10532. Files opened with the #fopen directive are automatically closed
  10533. when scene parsing completes however you may close a file using
  10534. the #fclose directive. The syntax is as follows:
  10535.  
  10536. FCLOSE_DIRECTIVE:
  10537.   #fclose FILE_HANDLE_IDENTIFIER
  10538. Where FILE_HANDLE_IDENTIFIER is previously opened file opened
  10539. with the #fopen directive. See "The #fopen Directive".
  10540.  
  10541.  
  10542. 4.2.3.3   The #read Directive
  10543. You may read string, float or vector values from a plain ASCII
  10544. text file directly into POV-Ray variables using the #read
  10545. directive. The file must first be opened in "read" mode using the
  10546. #fopen directive. The syntax for #read is as follows:
  10547.  
  10548. READ_DIRECTIVE:
  10549.   #read( FILE_HANDLE_IDENTIFIER,
  10550.   DATA_IDENTIFIER[,DATA_IDENTIFIER]...)
  10551. DATA_IDENTIFIER:
  10552.   UNDECLARED_IDENTIFIER   |   FLOAT_IDENTIFIER   |
  10553.   VECTOR_IDENTIFIER   |   STRING_IDENTIFIER
  10554. Where FILE_HANDLE_IDENTIFIER is the previously opened file. It is
  10555. followed by one or more DATA_IDENTIFIERs separated by commas. The
  10556. parentheses around the identifier list are required. A
  10557. DATA_IDENTIFIER is any undeclared identifier or any previously
  10558. declared string identifier, float identifier, or vector
  10559. identifier. Undefined identifiers will be turned into global
  10560. identifiers of the type determined by the data which is read.
  10561. Previously defined identifiers remain at whatever global/local
  10562. status they had when originally created. Type checking is
  10563. performed to insure that the proper type data is read into these
  10564. identifiers.
  10565.  
  10566. The format of the data to be read must be a series of valid
  10567. string literals, float literals, or vector literals separated by
  10568. commas. Expressions or identifiers are not permitted in the data
  10569. file however unary minus signs and exponential notation are
  10570. permitted on float values.
  10571.  
  10572. If you attempt to read past end-of-file, the file is
  10573. automatically closed and the FILE_HANDLE_IDENTIFIER is deleted
  10574. from the symbol table.  This means that the boolean function
  10575. defined(IDENTIFIER) can be used to detect end-of-file.  For
  10576. example:
  10577.  
  10578.   #fopen MyFile "mydata.txt" read
  10579.   #while (defined(MyFile))
  10580.     #read (MyFile,Var1,Var2,Var3)
  10581.     ...
  10582.   #end
  10583.  
  10584. 4.2.3.4   The #write Directive
  10585. You may write string, float or vector values to a plain ASCII
  10586. text file from POV-Ray variables using the #write directive. The
  10587. file must first be opened in either write or append mode using
  10588. the #fopen directive. The syntax for #write is as follows:
  10589.  
  10590. WRITE_DIRECTIVE:
  10591.   #write( FILE_HANDLE_ITEM, DATA_ITEM[,DATA_ITEM]...)
  10592. DATA_ITEM:
  10593.   FLOAT   |   VECTOR   |   STRING
  10594. Where FILE_HANDLE_IDENTIFIER is the previously opened file. It is
  10595. followed by one or more DATA_ITEMs separated by commas. The
  10596. parentheses around the identifier list are required. A DATA_ITEM
  10597. is any valid string expression, float expression, or vector
  10598. expression. Float expressions are evaluated and written as signed
  10599. float literals. If you require format control, you should use the
  10600. str(VALUE,L,P) function to convert it to a formatted string. See
  10601. "String Functions" for details on the str function. Vector
  10602. expressions are evaluated into three signed float constants and
  10603. are written with angle brackets and commas in standard POV-Ray
  10604. vector notation. String expressions are evaluated and written as
  10605. specified.
  10606.  
  10607. Note that data read by the #read directive must have comma
  10608. delimiters between values and quotes around string data but the
  10609. #write directive does not automatically output commas or quotes.
  10610. For example the following #read directive reads a string, float
  10611. and vector.
  10612.  
  10613.  #read (MyFile,MyString,MyFloat,MyVect)
  10614. It expects to read something like:
  10615.  
  10616.  "A quote delimeted string" , -123.45, <1,2,-3>
  10617. The POV-Ray code to write this might be:
  10618.  
  10619.  #declare Val1 = -123.45;
  10620.  #declare Vect1 = <1,2,-3>;
  10621.  #write (MyFile,"\"A quote delimited
  10622. string\",",Val1,",",Vect1,"\n")
  10623. See "String Literals" and "Text Formatting" for details on
  10624. writing special characters such as quotes, newline, etc.
  10625.  
  10626.  
  10627. 4.2.4     The #default Directive
  10628. POV-Ray creates a default texture when it begins processing. You
  10629. may change those defaults as described below. Every time you
  10630. specify a texture statement, POV-Ray creates a copy of the
  10631. default texture. Anything you put in the texture statement
  10632. overrides the default settings. If you attach a pigment, normal,
  10633. or finish to an object without any texture statement then POV-Ray
  10634. checks to see if a texture has already been attached. If it has a
  10635. texture then the pigment, normal or finish will modify the
  10636. existing texture. If no texture has yet been attached to the
  10637. object then the default texture is copied and the pigment, normal
  10638. or finish will modify that texture.
  10639.  
  10640. You may change the default texture, pigment, normal or finish
  10641. using the language directive #default as follows:
  10642.  
  10643. DEFAULT_DIRECTIVE:
  10644.   #default {DEFAULT_ITEM }
  10645. DEFAULT_ITEM:
  10646.   TEXTURE   |   PIGMENT   |   NORMAL   |   FINISH
  10647. For example:
  10648.  
  10649.  #default{
  10650.    texture{
  10651.      pigment{rgb <1,0,0>}
  10652.      normal{bumps 0.3}
  10653.      finish{ambient 0.4}
  10654.    }
  10655.  }
  10656. means objects will default to red bumps and slightly high ambient
  10657. finish.  Note also you may change just part of it like this:
  10658.  
  10659.  #default {
  10660.   pigment {rgb <1,0,0>}
  10661.  }
  10662. This still changes the pigment of the default texture. At any
  10663. time there is only one default texture made from the default
  10664. pigment, normal and finish. The example above does not make a
  10665. separate default for pigments alone. Note that the special
  10666. textures tiles and material_map or a texture with a texture_map
  10667. may not be used as defaults.
  10668.  
  10669. You may change the defaults several times throughout a scene as
  10670. you wish. Subsequent #default statements begin with the defaults
  10671. that were in effect at the time. If you wish to reset to the
  10672. original POV-Ray defaults then you should first save them as
  10673. follows:
  10674.  
  10675.  //At top of file
  10676.  #declare Original_Default = texture {}
  10677. later after changing defaults you may restore it with...
  10678.  
  10679.  #default {texture {Original_Default}}
  10680. If you do not specify a texture for an object then the default
  10681. texture is attached when the object appears in the scene. It is
  10682. not attached when an object is declared. For example:
  10683.  
  10684.  #declare My_Object =
  10685.   sphere{ <0,0,0>, 1 } // Default texture not applied
  10686.   object{ My_Object }  // Default texture added here
  10687. You may force a default texture to be added by using an empty
  10688. texture statement as follows:
  10689.  
  10690.  #declare My_Thing =
  10691.   sphere { <0,0,0>, 1 texture {} } // Default texture applied
  10692. The original POV-Ray defaults for all items are given throughout
  10693. the documentation under each appropriate section.
  10694.  
  10695.  
  10696. 4.2.5     The #version Directive
  10697. As POV-Ray as evolved from version 1.0 through 3.1 we have made
  10698. every effort to maintain some amount of backwards compatibility
  10699. with earlier versions.  Some old or obsolete features can be
  10700. handled directly without any special consideration by the user.
  10701. Some old or obsolete features can no longer be handled at all.
  10702. However some old features can still be used if you warn POV-Ray
  10703. that this is an older scene.  The #version directive can be used
  10704. to switch version compatibility to different setting several
  10705. times throughout a scene file.  The syntax is:
  10706.  
  10707. VERSION_DIRECTIVE:
  10708.   #version FLOAT;
  10709. Note that there should be a semi-colon after the float expression
  10710. in a #version directive. This semi-colon is new with POV-Ray
  10711. version 3.1. If omitted, it generates a warning and some macros
  10712. may not work properly.
  10713.  
  10714. Additionally you may use the Version=n.n option or the +MVn.n
  10715. switch to establish the initial setting.  See "Language Version"
  10716. for details. For example one feature introduced in 2.0 that was
  10717. incompatible with any 1.0 scene files is the parsing of float
  10718. expressions. Using #version 1.0 turns off expression parsing as
  10719. well as many warning messages so that nearly all 1.0 files will
  10720. still work. Naturally the default setting for this option is
  10721. #version 3.1.
  10722.  
  10723. NOTE: Some obsolete or re-designed features are totally
  10724. unavailable in POV-Ray 3.1 REGARDLES OF THE VERSION SETTING.
  10725. Details on these features are noted throughout this
  10726. documentation.
  10727.  
  10728. The built-in float identifier version contains the current
  10729. setting of the version compatibility option. See "Built-in Float
  10730. Identifiers".  Together with the built-in version identifier the
  10731. #version directive allows you to save and restore the previous
  10732. values of this compatibility setting. The new #local identifier
  10733. option is especially useful here. For example suppose mystuff.inc
  10734. is in version 1 format. At the top of the file you could put:
  10735.  
  10736.  #local Temp_Vers = version;  // Save previous value
  10737.  #version 1.0;         // Change to 1.0 mode
  10738.  ... // Version 1.0 stuff goes here...
  10739.  #version Temp_Vers;      // Restore previous version
  10740. Future versions of POV-Ray may not continue to maintain full
  10741. backward compatibility even with the #version directive. We
  10742. strongly encourage you to phase in 3.1 syntax as much as
  10743. possible.
  10744.  
  10745.  
  10746. 4.2.6     Conditional Directives
  10747. POV-Ray 3.0 allows a variety of new language directives to
  10748. implement conditional parsing of various sections of your scene
  10749. file. This is especially useful in describing the motion for
  10750. animations but it has other uses as well. Also available is a
  10751. #while loop directive. You may nest conditional directives 200
  10752. levels deep.
  10753.  
  10754.  
  10755. 4.2.6.1   The #if...#else...#end Directives
  10756. The simplest conditional directive is a traditional #if
  10757. directive. It is of the form...
  10758.  
  10759. IF_DIRECTIVE:
  10760.   #if ( Cond ) TOKENS...  [#else TOKENS...] #end
  10761. The TOKENS are any number of POV-Ray keyword, identifiers, or
  10762. punctuation and ( Cond ) is a float expression that is
  10763. interpreted as a boolean value. The parentheses are required.
  10764. The #end directive is required.  A value of 0.0 is false and any
  10765. non-zero value is true. Note that extremely small values of about
  10766. 1e-10 are considered zero in case of round off errors. If Cond is
  10767. true, the first group of tokens is parsed normally and the second
  10768. set is skipped.  If false, the first set is skipped and the
  10769. second set is parsed.  For example:
  10770.  
  10771.  #declare Which=1;
  10772.  #if (Which)
  10773.    box{0,1}
  10774.  #else
  10775.    sphere{0,1}
  10776.  #end
  10777. The box is parsed and the sphere is skipped.  Changing the value
  10778. of Which to 0 means the box is skipped and the sphere is used.
  10779. The #else directive and second token group is optional. For
  10780. example:
  10781.  
  10782.  #declare Which=1;
  10783.  #if (Which)
  10784.    box{0,1}
  10785.  #end
  10786. Changing the value of Which to 0 means the box is removed.
  10787.  
  10788.  
  10789. 4.2.6.2   The #ifdef and #ifndef Directives
  10790. The #ifdef and #ifndef directive are similar to the #if directive
  10791. however they is used to determine if an identifier has been
  10792. previously declared.
  10793.  
  10794. IFDEF_DIRECTIVE:
  10795.   #ifdef ( IDENTIFIER ) TOKENS...  [#else TOKENS...] #end
  10796. IFNDEF_DIRECTIVE:
  10797.   #ifndef ( IDENTIFIER ) TOKENS...  [#else TOKENS...] #end
  10798. If the IDENTIFIER exists then the first group of tokens is parsed
  10799. normally and the second set is skipped.  If false, the first set
  10800. is skipped and the second set is parsed.  This is especially
  10801. useful for replacing an undefined item with a default.  For
  10802. example:
  10803.  
  10804.  #ifdef (User_Thing)
  10805.  
  10806.   // This section is parsed if the
  10807.   // identifier "User_Thing" was
  10808.   // previously declared
  10809.   object{User_Thing} // invoke identifier
  10810.  #else
  10811.   // This section is parsed if the
  10812.   // identifier "User_Thing" was not
  10813.   // previously declared
  10814.   box{<0,0,0>,<1,1,1>} // use a default
  10815.  #end
  10816.   // End of conditional part
  10817. The #ifndef directive works the opposite.  The first group is
  10818. parsed if the identifier is not defined.  As with the #if
  10819. directive, the #else clause is optional and the #end directive is
  10820. required.
  10821.  
  10822.  
  10823. 4.2.6.3   The #switch, #case, #range and #break Directives
  10824. A more powerful conditional is the #switch directive. The syntax
  10825. is as follows...
  10826.  
  10827. SWITCH_DIRECTIVE:
  10828.   #switch ( Switch_Value ) SWITCH_CLAUSE...  [#else TOKENS...]
  10829.   #end
  10830. SWITCH_CLAUSE:
  10831.   #case( Case_Value ) TOKENS...  [#break]      |
  10832.   #range( Low_Value , High_Value ) TOKENS...  [#break]
  10833. The TOKENS are any number of POV-Ray keyword, identifiers, or
  10834. punctuation and ( Switch_Value ) is a float expression. The
  10835. parentheses are required.  The #end directive is required.  The
  10836. SWITCH_CLAUSE comes in two varieties.  In the #case variety, the
  10837. float Switch_Value is compared to the float Case_Value.  If they
  10838. are equal, the condition is true.  Note that values whose
  10839. difference is less than 1e-10 are considered equal in case of
  10840. round off errors.  In the #range variety, Low_Value Switch and
  10841. High_Value are floats separated by a comma and enclosed in
  10842. parentheses.  If Low_Value <= Switch_Value and
  10843. Switch_Value<=High_Value then the condition is true.
  10844.  
  10845. In either variety, if the clause's condition is true, that
  10846. clause's tokens are parsed normally and parsing continues until a
  10847. #break, #else or #end directive is reached. If the condition is
  10848. false, POV-Ray skips until another #case or #range is found.
  10849.  
  10850. There may be any number of #case or #range clauses in any order
  10851. you want. If a clause evaluates true but no #break is specified,
  10852. the parsing will fall through to the next #case or #range and
  10853. that clause conditional is evaluated.  Hitting #break while
  10854. parsing a successful section causes an immediate jump to the #end
  10855. without processing subsequent sections, even if a subsequent
  10856. condition would also have been satisfied.
  10857.  
  10858. An optional #else clause may be the last clause.  It is only
  10859. executed if the clause before it was a false clause.
  10860.  
  10861. Here is an example:
  10862.  
  10863.  #switch (VALUE)
  10864.   #case (TEST_1)
  10865.    // This section is parsed if VALUE=TEST_1
  10866.   #break //First case ends
  10867.   #case (TEST_2)
  10868.    // This section is parsed if VALUE=TEST_2
  10869.   #break //Second case ends
  10870.   #range (LOW_1,HIGH_1)
  10871.    // This section is parsed if (VALUE>=LOW_1)&(VALUE<=HIGH_1)
  10872.   #break //Third case ends
  10873.   #range (LOW_2,HIGH_2)
  10874.    // This section is parsed if (VALUE>=LOW_2)&(VALUE<=HIGH_2)
  10875.   #break //Fourth case ends
  10876.   #else
  10877.    // This section is parsed if no other case or
  10878.    // range is true.
  10879.  #end // End of conditional part
  10880.  
  10881. 4.2.6.4   The #while...#end Directive
  10882. The #while directive is a looping feature that makes it easy to
  10883. place multiple objects in a pattern or other uses.
  10884.  
  10885. WHILE_DIRECTIVE:
  10886.   #while ( Cond ) TOKENS... #end
  10887. The TOKENS are any number of POV-Ray keyword, identifiers, or
  10888. punctuation marks which are the body of the loop.  The #while
  10889. directive is followed by a float expression that evaluates to a
  10890. boolean value. A value of 0.0 is false and any non-zero value is
  10891. true. Note that extremely small values of about 1e-10 are
  10892. considered zero in case of round off errors. The parentheses
  10893. around the expression are required. If the condition is true
  10894. parsing continues normally until an #end directive is reached. At
  10895. the end, POV-Ray loops back to the #while directive and the
  10896. condition is re-evaluated. Looping continues until the condition
  10897. fails. When it fails, parsing continues after the #end directive.
  10898. Note it is possible for the condition to fail the first time and
  10899. the loop is totally skipped.  It is up to the user to insure that
  10900. something inside the loop changes so that it eventually
  10901. terminates.  Here is a properly constructed loop example:
  10902.  
  10903.  #declare Count=0;
  10904.  #while (Count < 5)
  10905.   object{MyObject translate x*3*Count}
  10906.   #declare Count=Count+1;
  10907.  #end
  10908. This example places five copies of MyObject in a row spaced three
  10909. units apart in the x-direction.
  10910.  
  10911.  
  10912. 4.2.7     User Message Directives
  10913. With the addition of conditional and loop directives, the POV-Ray
  10914. language has the potential to be more like an actual programming
  10915. language. This means that it will be necessary to have some way
  10916. to see what is going on when trying to debug loops and
  10917. conditionals. To fulfill this need we have added the ability to
  10918. print text messages to the screen. You have a choice of five
  10919. different text streams to use including the ability to generate a
  10920. fatal error if you find it necessary. Limited formatting is
  10921. available for strings output by this method.
  10922.  
  10923.  
  10924. 4.2.7.1   Text Message Streams
  10925. The syntax for a text message is any of the following:
  10926.  
  10927. TEXT_STREAM_DIRECTIVE:
  10928.   #debug STRING       |
  10929.   #error STRING       |
  10930.   #render STRING      |
  10931.   #statistics STRING  |
  10932.   #warning STRING
  10933. Where STRING is any valid string of text including string
  10934. identifiers or functions which return strings. For example:
  10935.  
  10936.  #switch (clock*360)
  10937.   #range (0,180)
  10938.    #render "Clock in 0 to 180 range\n"
  10939.   #break
  10940.   #range (180,360)
  10941.    #render "Clock in 180 to 360 range\n"
  10942.   #break
  10943.   #else
  10944.    #warning "Clock outside expected range\n"
  10945.    #warning concat("Value is:",str(clock*360,5,0),"\n")
  10946.  #end
  10947. There are seven distinct text streams that POV-Ray uses for
  10948. output. You may output only to five of them. On some versions of
  10949. POV-Ray, each stream is designated by a particular color. Text
  10950. from these streams are displayed whenever it is appropriate so
  10951. there is often an intermixing of the text. The distinction is
  10952. only important if you choose to turn some of the streams off or
  10953. to direct some of the streams to text files. On some systems you
  10954. may be able to review the streams separately in their own scroll-
  10955. back buffer. See "Directing Text Streams to Files" for details on
  10956. re-directing the streams to a text file.
  10957.  
  10958. Here is a description of how POV-Ray uses each stream. You may
  10959. use them for whatever purpose you want except note that use of
  10960. the #error stream causes a fatal error after the text is
  10961. displayed.
  10962.  
  10963. Debug: This stream displays debugging messages. It was primarily
  10964. designed for developers but this and other streams may also be
  10965. used by the user to display messages from within their scene
  10966. files.
  10967.  
  10968. Fatal: This stream displays fatal error messages. After
  10969. displaying this text, POV-Ray will terminate. When the error is a
  10970. scene parsing error, you may be shown several lines of scene text
  10971. that leads up to the error.
  10972.  
  10973. Render: This stream displays information about what options you
  10974. have specified to render the scene. It includes feedback on all
  10975. of the major options such as scene name, resolution, animation
  10976. settings, anti-aliasing and others.
  10977.  
  10978. Statistics: This stream displays statistics after a frame is
  10979. rendered. It includes information about the number of rays
  10980. traced, the length of time of the processing and other
  10981. information.
  10982.  
  10983. Warning: This stream displays warning messages during the parsing
  10984. of scene files and other warnings. Despite the warning, POV-Ray
  10985. can continue to render the scene.
  10986.  
  10987. The banner and status streams can not be accessed by the user.
  10988.  
  10989.  
  10990. 4.2.7.2   Text Formatting
  10991. Some escape sequences are available to include non-printing
  10992. control characters in your text. These sequences are similar to
  10993. those used in string literals in the C programming language. The
  10994. sequences are:
  10995. "\a" Bell or       0x0
  10996.      alarm,        7
  10997. "\b" Backspace,    0x0
  10998.                    8
  10999. "\f" Form feed,    0x0
  11000.                    C
  11001. "\n" New line      0x0
  11002.      (line feed)   A
  11003. "\r" Carriage      0x0
  11004.      return        D
  11005. "\t" Horizontal    0x0
  11006.      tab           9
  11007. "\v" Vertical      0x0
  11008.      tab           B
  11009. "\0" Null          0x0
  11010.                    0
  11011. "\\" Backslash     0x5
  11012.                    C
  11013. "\'" Single        0x2
  11014.      quote         7
  11015. "\"" Double        0x2
  11016.      quote         2
  11017. For example:
  11018.  
  11019.  #debug "This is one line.\nBut this is another"
  11020. Depending on what platform you are using, they may not be fully
  11021. supported for console output. However they will appear in any
  11022. text file if you re-direct a stream to a file.
  11023.  
  11024. Note that most of these control characters only apply in text
  11025. message directives and #write directives which write strings They
  11026. are not implemented for other string usage in POV-Ray such as
  11027. text objects or file names.
  11028.  
  11029.  
  11030. 4.2.8     User Defined Macros
  11031. New in POV-Ray 3.1 are user defined macros with parameters. This
  11032. new feature, along with the ability to declare #local variables,
  11033. turns the POV-Ray Language into a fully functional programming
  11034. language. It should now be possible to write scene generation
  11035. utilities that previously required external utilities.
  11036.  
  11037.  
  11038. 4.2.8.1   The #macro Directive
  11039. The syntax for declaring a macro is:
  11040.  
  11041. MACRO_DEFINITION:
  11042.   #macro IDENTIFIER ( [PARAM_IDENT] [,  PARAM_IDENT]... )
  11043.   TOKENS... #end
  11044. Where IDENTIFIER is the name of the macro and PARAM_IDENTs are a
  11045. list of zero or more formal parameter identifiers separated by
  11046. commas and enclosed by parentheses. The parentheses are required
  11047. even if no parameters are specified.
  11048.  
  11049. The TOKENS are any number of POV-Ray keyword, identifiers, or
  11050. punctuation marks which are the body of the macro.  The body of
  11051. the macro may contain almost any POV-Ray syntax items you desire.
  11052. It is terminated my the #end directive. Note however that any
  11053. conditional directives such as #if...#end, #while...#end, etc.
  11054. must be fully nested inside or outside the macro so that the
  11055. corresponding #end directives pair-up properly. Also you may not
  11056. nest macro declarations.
  11057.  
  11058. A macro must be declared before it is invoked.  All macro names
  11059. are global in scope and permanent in duration.  You may redefine
  11060. a macro by another #macro directive with the same name.  The
  11061. previous definition is lost.  Macro names respond to #ifdef,
  11062. #ifndef, and #undef directives.  See "The #ifdef and #ifndef
  11063. Directives" and "Destroying Identifiers with #undef".
  11064.  
  11065.  
  11066. 4.2.8.2   Invoking Macros
  11067. You invoke the macro by specifying the macro name followed by a
  11068. list of zero or more actual parameters enclosed in parentheses
  11069. and separated by commas.  The number of actual parameters must
  11070. match the number of formal parameters in the definition.  The
  11071. parentheses are required even if no parameters are specified.
  11072. The syntax is:
  11073.  
  11074. MACRO_INVOCATION:
  11075.   MACRO_IDENTIFIER ( [ACTUAL_PARAM] [,  ACTUAL_PARAM]... )
  11076. ACTUAL_PARAM:
  11077.   IDENTIFIER          |
  11078.   RVALUE
  11079. An RVALUE is any value that can legally appear to the right of an
  11080. equals sign in a #declare or #local declaration. See "Declaring
  11081. identifiers" for information on RVALUEs.  When the macro is
  11082. invoked, a new local symbol table is created.  The actual
  11083. parameters are assigned to formal parameter identifiers as local,
  11084. temporary variables.  POV-Ray jumps to the body of the macro and
  11085. continues parsing until the matching #end directive is reached.
  11086. There, the local variables created by the parameters are
  11087. destroyed as well as any local identifiers expressly created in
  11088. the body of the macro.  It then resumes parsing at the point
  11089. where the macro was invoked.  It is as though the body of the
  11090. macro was cut and pasted into the scene at the point where the
  11091. macro was invoked.
  11092.  
  11093. Here is a simple macro that creates a window frame object when
  11094. you specify the inner and outer dimensions.
  11095.  
  11096.  #macro Make_Frame
  11097. (OuterWidth,OuterHeight,InnerWidth,InnerHeight,Depth)
  11098.   #local Horz = (OuterHeight-InnerHeight)/2;
  11099.   #local Vert = (OuterWidth-InnerWidth)/2;
  11100.   difference
  11101.   {
  11102.    box{<0,0,0>,<OuterWidth,OuterHeight,Depth>}
  11103.    box{<Vert,Hoiz,-0.1>,<OuterWidth-Vert,OuterHeight-
  11104. Horz,Depth+0.1>}
  11105.   }
  11106.  #end
  11107.  Make_Frame(8,10,7,9,1) //invoke the macro
  11108. In this example, the macro has five float parameters.  The actual
  11109. parameters (the values 8, 10, 7, 9, and 1) are assigned to the
  11110. five identifiers in the #macro formal parameter list.  It is as
  11111. though you had used the following five lines of code.
  11112.  
  11113.  #local OuterWidth = 8;
  11114.  #local OuterHeight = 10;
  11115.  #local InnerWidth, = 7;
  11116.  #local InnerHeight = 9;
  11117.  #local Depth = 1;
  11118. These five identifiers are stored in the same symbol table as any
  11119. other local identifier such as Horz or Vert in this example.  The
  11120. parameters and local variables are all destroyed when the #end
  11121. statement is reached.  See "Identifier Name Collisions" for a
  11122. detailed discussion of how local identifiers, parameters, and
  11123. global identifiers work when a local identifier has the same name
  11124. as a previously declared identifier.
  11125.  
  11126.  
  11127. 4.2.8.3   Are POV-Ray Macros a Function or a Macro?
  11128. POV-Ray macros are a strange mix of macros and functions.  In
  11129. traditional computer programming languages, a macro works
  11130. entirely by token substitution.  The body of the routine is
  11131. inserted into the invocation point by simply copying the tokens
  11132. and parsing them as if they had been cut and pasted in place.
  11133. Such cut-and-paste substitution is often called macro
  11134. substitution because it is what macros are all about.  In this
  11135. respect, POV-Ray macros are exactly like traditional macros in
  11136. that they use macro substitution for the body of the macro.
  11137. However traditional macros also use this cut-and-paste
  11138. substitution strategy for parameters but POV-Ray does not.
  11139.  
  11140. Suppose you have a macro in the C programming language
  11141. Typical_Cmac(Param) and you invoke it as Typical_Cmac(else A=B).
  11142. Anywhere that Param appears in the macro body, the four tokens
  11143. else, A, =, and B are substituted into the program code using a
  11144. cut-and-paste operation.  No type checking is performed because
  11145. anything is legal.  The ability to pass an arbitrary group of
  11146. tokens via a macro parameter is a powerful (and sadly often
  11147. abused) feature of traditional macros.
  11148.  
  11149. After careful deliberation, we have decided against this type of
  11150. parameters for our macros.  The reason is that POV-Ray uses
  11151. commas more frequently in its syntax than do most programming
  11152. languages.  Suppose you create a macro that is designed to
  11153. operate on one vector and two floats.  It might be defined
  11154. OurMac(V,F1,F2).  If you allow arbitrary strings of tokens and
  11155. invoke a macro such as OurMac(<1,2,3>,4,5) then it is impossible
  11156. to tell if this is a vector and two floats or if its 5 parameters
  11157. with the two tokens < and 1 as the first parameter.  If we design
  11158. the macro to accept 5 parameters then we cannot invoke it like
  11159. this... OurMac(MyVector,4,5).
  11160.  
  11161. Function parameters in traditional programming languages do not
  11162. use token substitution to pass values.  They create temporary,
  11163. local variables to store parameters that are either constant
  11164. values or identifier references which are in effect a pointer to
  11165. a variable.  POV-Ray macros use this function-like system for
  11166. passing parameters to its macros.  In our example
  11167. OurMac(<1,2,3>,4,5), POV-Ray sees the < and knows it must be the
  11168. start of a vector.  It parses the whole vector expression and
  11169. assigns it to the first parameter exactly as though you had used
  11170. the statement #local V=<1,2,3>;.
  11171.  
  11172. Although we say that POV-Ray parameters are more like traditional
  11173. function parameters than macro parameters, there still is one
  11174. difference.  Most languages require you to declare the type of
  11175. each parameter in the definition before you use it but POV-Ray
  11176. does not.  This should be no surprise because Most languages
  11177. require you to declare the type of any identifier before you use
  11178. it but POV-Ray does not.  This means that if you pass the wrong
  11179. type value in a POV-Ray macro parameter, it may not generate an
  11180. error until you reference the identifier in the macro body.  No
  11181. type checking is performed as the parameter is passed.  So in
  11182. this very limited respect, POV-Ray parameters are somewhat macro-
  11183. like but are mostly function-like.
  11184.  
  11185.  
  11186. 4.2.8.4   Returning a Value Like a Function
  11187. POV-Ray macros have a variety of uses.  Like most macros, they
  11188. provide a parameterized way to insert arbitrary code into a scene
  11189. file.  However most POV-Ray macros will be used like functions or
  11190. procedures in a traditional programming language.  This is
  11191. especially true because the POV-Ray language has no user-defined
  11192. functions or procedures.  Macros are designed to fill all of
  11193. these roles.
  11194.  
  11195. When the body of a macro consists of statements that create an
  11196. entire item such as an object, texture, etc. then the macro acts
  11197. like a function which returns a single value.  The Make_Frame
  11198. macro example in the section "Invoking Macros" above is such a
  11199. macro which returns a value that is an object.  Here are some
  11200. examples of how you might invoke it.
  11201.  
  11202.  union {  //make a union of two objects
  11203.    object{ Make_Frame(8,10,7,9,1) translate  20*x}
  11204.    object{ Make_Frame(8,10,7,9,1) translate -20*x}
  11205.  }
  11206.  #declare BigFrame = object{ Make_Frame(8,10,7,9,1)}
  11207.  #declare SmallFrame = object{ Make_Frame(5,4,4,3,0.5)}
  11208. Because no type checking is performed on parameters and because
  11209. the expression syntax for floats, vectors, and colors is
  11210. identical, you can create clever macros which work on all three.
  11211. See the sample scene MACRO3.POV which includes this macro to
  11212. interpolate values.
  11213.  
  11214. // Define the macro.  Parameters are:
  11215. //   T:  Middle value of time
  11216. //   T1: Initial time
  11217. //   T2: Final time
  11218. //   P1: Initial position (may be float, vector or color)
  11219. //   P2: Final position (may be float, vector or color)
  11220. //   Result is a value between P1 and P2 in the same proportion
  11221. //    as T is between T1 and T2.
  11222. #macro Interpolate(T,T1,T2,P1,P2)
  11223.    (P1+(T1+T/(T2-T1))*(P2-P1))
  11224. #end
  11225. You might invoke it with P1 and P2 as floats, vectors, or colors
  11226. as follows.
  11227.  
  11228.   sphere{
  11229.     Interpolate(I,0,15,<2,3,4>,<9,8,7>),  //center location is
  11230. vector
  11231.     Interpolate(I,0,15,3.0,5.5)           //radius is float
  11232.     pigment{
  11233.       color Interpolate(I,0,15,rgb<1,1,0>,rgb<0,1,1>)
  11234.     }
  11235.   }
  11236. As the float value I varies from 0 to 15, the location, radius,
  11237. and color of the sphere vary accordingly.
  11238.  
  11239. There is a danger in using macros as functions.  In a traditional
  11240. programming language function, the result to be returned is
  11241. actually assigned to a temporary variable and the invoking code
  11242. treats it as a variable of a given type.  However macro
  11243. substitution may result in invalid or undesired syntax.  Note the
  11244. definition of the macro Interpolate above has an outermost set of
  11245. parentheses.  If those parentheses are omitted, it will not
  11246. matter in the examples above, but what if you do this...
  11247.  
  11248.  #declare Value = Interpolate(I,0,15,3.0,5.5)*15;
  11249. The end result is as if you had done...
  11250.  
  11251.  #declare Value = P1+(T1+T/(T2-T1))*(P2-P1) * 15;
  11252. which is syntactically legal but not mathematically correct
  11253. because the P1 term is not multiplied.  The parentheses in the
  11254. original example solves this problem.  The end result is as if
  11255. you had done...
  11256.  
  11257.  #declare Value = (P1+(T1+T/(T2-T1))*(P2-P1)) * 15;
  11258. which is correct.
  11259.  
  11260.  
  11261. 4.2.8.5   Returning Values Via Parameters
  11262. Sometimes it is necessary to have a macro return more than one
  11263. value or you may simply prefer to return a value via a parameter
  11264. as is typical in traditional programming language procedures.
  11265. POV-Ray macros are capable of returning values this way.  The
  11266. syntax for POV-Ray macro parameters says that the actual
  11267. parameter may be an IDENTIFIER or an RVALUE.  Values may only be
  11268. returned via a parameter if the parameter is an IDENTIFIER.
  11269. Parameters that are RVALUES are constant values that cannot
  11270. return information.  An RVALUE is anything that legally may
  11271. appear to the right of an equals sign in a #declare or #local
  11272. directive.  For example consider the following trivial macro
  11273. which rotates an object about the x-axis.
  11274.  
  11275.  #macro Turn_Me(Stuff,Degrees)
  11276.    #declare Stuff = object{Stuff rotate x*Degrees}
  11277.  #end
  11278. This attempts to re-declare the identifier Stuff as the rotated
  11279. version of the object.  However the macro might be invoked with
  11280. Turn_Me(box{0,1},30) which uses a box object as an RVALUE
  11281. parameter.  This won't work because the box is not an identifier.
  11282. You can however do this
  11283.  
  11284.    #declare MyObject=box{0,1}
  11285.    Turn_Me(MyObject,30)
  11286. The identifier MyObject now contains the rotated box.
  11287.  
  11288. See "Identifier Name Collisions" for a detailed discussion of how
  11289. local identifiers, parameters, and global identifiers work when a
  11290. local identifier has the same name as a previously declared
  11291. identifier.
  11292.  
  11293. While it is obvious that MyObject is an identifier and box{0,1}
  11294. is not, it should be noted that Turn_Me(object{MyObject},30) will
  11295. not work because object{MyObject} is considered an object
  11296. statement and is not a pure identifier.  This mistake is more
  11297. likely to be made with float identifiers verses float
  11298. expressions.  Consider these examples.
  11299.  
  11300.   #declare Value=5.0;
  11301.   MyMacro(Value)     //MyMacro can change the value of Value
  11302. but...
  11303.   MyMacro(+Value)    //This version and the rest are not lone
  11304.   MyMacro(Value+0.0) // identifiers. They are float expressions
  11305.   MyMacro(Value*1.0) // which cannot be changed.
  11306. Although all four invocations of MyMacro are passed the value
  11307. 5.0, only the first may modify the value of the identifier.
  11308.  
  11309.  
  11310. 4.3  POV-Ray Coordinate System
  11311. Objects, lights and the camera are positioned using a typical 3D
  11312. coordinate system. The usual coordinate system for POV-Ray has
  11313. the positive y-axis pointing up, the positive x-axis pointing to
  11314. the right and the positive z-axis pointing into the screen. The
  11315. negative values of the axes point the other direction as shown in
  11316. the images in section "Understanding POV-Ray's Coordinate
  11317. System".
  11318.  
  11319. Locations within that coordinate system are usually specified by
  11320. a three component vector. The three values correspond to the x, y
  11321. and z directions respectively. For example, the vector <1,2,3>
  11322. means the point that's one unit to the right, two units up and
  11323. three units in front of the center of the universe at <0,0,0>.
  11324.  
  11325. Vectors are not always points though. They can also refer to an
  11326. amount to size, move or rotate a scene element or to modify the
  11327. texture pattern applied to an object.
  11328.  
  11329. The size, location, orientation, and deformation of items within
  11330. the coordinate system is controlled by modifiers called
  11331. transformations.  The follow sub-sections describe the
  11332. transformations and their usage.
  11333.  
  11334.  
  11335. 4.3.1     Transformations
  11336. The supported transformations are rotate, scale, and translate.
  11337. They are used to turn, size and move an object or texture. A
  11338. transformation matrix may also be used to specify complex
  11339. transformations directly. Groups of transformations may be merged
  11340. together and stored in a transformation identifier.  The syntax
  11341. for transformations is as follows.
  11342.  
  11343. TRANSFORMATION:
  11344.   rotate <Rotate_Amt>           |
  11345.   scale <Scale_Amt>                  |
  11346.   translate <Translate_Amt>          |
  11347.   transform TRANSFORM_IDENTIFIER     |
  11348.   matrix <Val00, Val01, Val02,
  11349.      Val10, Val11, Val12,
  11350.      Val20, Val21, Val22,
  11351.      Val30, Val31, Val32>
  11352. TRANSFORM_DECLARATION:
  11353.   #declare IDENTIFIER = transform{ TRANSFORMATION... }   |
  11354.   #local IDENTIFIER = transform{ TRANSFORMATION... }
  11355.  
  11356. 4.3.1.1   Translate
  11357. Items may be moved by adding a translate modifier. It consists of
  11358. the keyword translate followed by a vector expression. The three
  11359. terms of the vector specify the number of units to move in each
  11360. of the x, y and z directions. Translate moves the element
  11361. relative to it's current position. For example
  11362.  
  11363.  sphere { <10, 10, 10>, 1
  11364.   pigment { Green }
  11365.   translate <-5, 2, 1>
  11366.  }
  11367. will move the sphere from the location <10,10,10> to <5,12,11>.
  11368. It does not move it to the absolute location <-5,2,1>.
  11369. Translations are always relative to the item's location before
  11370. the move.  Translating by zero will leave the element unchanged
  11371. on that axis. For example:
  11372.  
  11373.  sphere { <10, 10, 10>, 1
  11374.   pigment { Green }
  11375.   translate 3*x // evaluates to <3,0,0> so move 3 units
  11376.          // in the x direction and none along y or z
  11377.  }
  11378.  
  11379. 4.3.1.2   Scale
  11380. You may change the size of an object or texture pattern by adding
  11381. a scale modifier. It consists of the keyword scale followed by a
  11382. vector expression. The three terms of the vector specify the
  11383. amount of scaling in each of the x, y and z directions.
  11384.  
  11385. Uneven scaling is used to stretch or squish an element. Values
  11386. larger than one stretch the element on that axis while values
  11387. smaller than one are used to squish it. Scale is relative to the
  11388. current element size. If the element has been previously re-sized
  11389. using scale then scale will size relative to the new size.
  11390. Multiple scale values may used.
  11391.  
  11392. For example
  11393.  
  11394.  sphere { <0,0,0>, 1
  11395.   scale <2,1,0.5>
  11396.  }
  11397. will stretch and smash the sphere into an ellipsoid shape that is
  11398. twice the original size along the x-direction, remains the same
  11399. size in the y-direction and is half the original size in the z-
  11400. direction.
  11401.  
  11402. If a lone float expression is specified it is promoted to a three
  11403. component vector whose terms are all the same. Thus the item is
  11404. uniformly scaled by the same amount in all directions. For
  11405. example:
  11406.  
  11407.  object {
  11408.   MyObject
  11409.   scale 5 // Evaluates as <5,5,5> so uniformly scale
  11410.       // by 5 in every direction.
  11411.  }
  11412.  
  11413. 4.3.1.3   Rotate
  11414. You may change the orientation of an object or texture pattern by
  11415. adding a rotate modifier. It consists of the keyword rotate
  11416. followed by a vector expression. The three terms of the vector
  11417. specify the number of degrees to rotate about each of the x-, y-
  11418. and z-axes.
  11419.  
  11420. Note that the order of the rotations does matter. Rotations occur
  11421. about the x-axis first, then the y-axis, then the z-axis. If you
  11422. are not sure if this is what you want then you should only rotate
  11423. on one axis at a time using multiple rotation statements to get a
  11424. correct rotation. As in
  11425.  
  11426.  rotate <0, 30, 0>  // 30 degrees around Y axis then,
  11427.  rotate <-20, 0, 0> // -20 degrees around X axis then,
  11428.  rotate <0, 0, 10>  // 10 degrees around Z axis.
  11429. Rotation is always performed relative to the axis. Thus if an
  11430. object is some distance from the axis of rotation it will not
  11431. only rotate but it will orbit about the axis as though it was
  11432. swinging around on an invisible string.
  11433.  
  11434. POV-Ray uses a left-handed rotation system. Using the famous
  11435. "Computer Graphics Aerobics" exercise, you hold up your left hand
  11436. and point your thumb in the positive direction of the axis of
  11437. rotation. Your fingers will curl in the positive direction of
  11438. rotation. Similarly if you point your thumb in the negative
  11439. direction of the axis your fingers will curl in the negative
  11440. direction of rotation.  See "Understanding POV-Ray's Coordinate
  11441. System" for a illustration.
  11442.  
  11443.  
  11444. 4.3.1.4   Matrix Keyword
  11445. The matrix keyword can be used to explicitly specify the
  11446. transformation matrix to be used for objects or textures. Its
  11447. syntax is:
  11448.  
  11449. MATRIX:
  11450.   matrix <Val00, Val01, Val02,
  11451.      Val10, Val11, Val12,
  11452.      Val20, Val21, Val22,
  11453.      Val30, Val31, Val32>
  11454. Where Val00 through Val32 are float expressions enclosed in angle
  11455. brackets and separated by commas.  Note this is not a vector.  It
  11456. is a set of 12 float expressions.  These floats specify the
  11457. elements of a 4 by 4 matrix with the fourth column implicitly set
  11458. to <0,0,0,1>. At any given point P, P=<px, py, pz>, is
  11459. transformed into the point Q, Q=<qx, qy, qz> by
  11460.  
  11461.  qx = Val00 * px + Val10 * py + Val20 * pz + Val30
  11462.  qy = Val01 * px + Val11 * py + Val21 * pz + Val31
  11463.  qz = Val02 * px + Val12 * py + Val22 * pz + Val32
  11464. Normally you won't use the matrix keyword because it's less
  11465. descriptive than the transformation commands and harder to
  11466. visualize. However the matrix command allows more general
  11467. transformation effects like shearing. The following matrix causes
  11468. an object to be sheared along the y-axis.
  11469.  
  11470.  object {
  11471.   MyObject
  11472.   matrix < 1, 1, 0,
  11473.        0, 1, 0,
  11474.        0, 0, 1,
  11475.        0, 0, 0 >
  11476.  }
  11477.  
  11478. 4.3.2     Transformation Order
  11479. Because rotations are always relative to the axis and scaling is
  11480. relative to the origin, you will generally want to create an
  11481. object at the origin and scale and rotate it first. Then you may
  11482. translate it into its proper position. It is a common mistake to
  11483. carefully position an object and then to decide to rotate it.
  11484. However because a rotation of an object causes it to orbit about
  11485. the axis, the position of the object may change so much that it
  11486. orbits out of the field of view of the camera!
  11487.  
  11488. Similarly scaling after translation also moves an object
  11489. unexpectedly. If you scale after you translate the scale will
  11490. multiply the translate amount. For example
  11491.  
  11492.  translate <5, 6, 7>
  11493.  scale 4
  11494. will translate to <20,24,28> instead of <5,6,7>. Be careful when
  11495. transforming to get the order correct for your purposes.
  11496.  
  11497.  
  11498. 4.3.3     Transform Identifiers
  11499. At times it is useful to combine together several transformations
  11500. and apply them in multiple places. A transform identifier may be
  11501. used for this purpose. Transform identifiers are declared as
  11502. follows:
  11503.  
  11504. TRANSFORM_DECLARATION:
  11505.   #declare IDENTIFIER = transform{ TRANSFORMATION... }   |
  11506.   #local IDENTIFIER = transform{ TRANSFORMATION... }
  11507. Where IDENTIFIER is the name of the identifier up to 40
  11508. characters long and TRANSFORMATION is any valid transformation
  11509. modifier.  See "#declare vs. #local" for information on
  11510. identifier scope.  Here is an example...
  11511.  
  11512.  #declare MyTrans = transform {
  11513.    rotate ThisWay
  11514.    scale SoMuch
  11515.    rotate -ThisWay
  11516.    scale Bigger
  11517.    translate OverThere
  11518.    rotate WayAround
  11519.   }
  11520. A transform identifier is invoked by the transform keyword
  11521. without any brackets as shown here:
  11522.  
  11523.  object {
  11524.   MyObject      // Get a copy of MyObject
  11525.   transform MyTrans // Apply the transformation
  11526.   translate -x*5   // Then move it 5 units left
  11527.  }
  11528.  object {
  11529.   MyObject      // Get another copy of MyObject
  11530.   transform MyTrans // Apply the same transformation
  11531.   translate x*5   // Then move this one 5 units right
  11532.  }
  11533. On extremely complex CSG objects with lots of components it may
  11534. speed up parsing if you apply a declared transformation rather
  11535. than the individual translate, rotate, scale, or matrix
  11536. modifiers. The transform is attached just once to each component.
  11537. Applying each individual translate, rotate, scale, or matrix
  11538. modifiers takes longer. This only affects parsing - rendering
  11539. works the same either way.
  11540.  
  11541.  
  11542. 4.3.4     Transforming Textures and Objects
  11543. When an object is transformed all textures attached to the object
  11544. at that time are transformed as well. This means that if you have
  11545. a translate, rotate, scale, or matrix modifier in an object
  11546. before a texture, then the texture will not be transformed. If
  11547. the transformation is after the texture then the texture will be
  11548. transformed with the object. If the transformation is inside the
  11549. texture statement then only the texture is affected. The shape
  11550. remains the same. For example:
  11551.  
  11552.  sphere { 0, 1
  11553.   texture { Jade } // texture identifier from TEXTURES.INC
  11554.   scale 3      // this scale affects both the
  11555.            // shape and texture
  11556.  }
  11557.  sphere { 0, 1
  11558.   scale 3      // this scale affects the shape only
  11559.   texture { Jade }
  11560.  }
  11561.  sphere { 0, 1
  11562.   texture {
  11563.    Jade
  11564.    scale 3     // this scale affects the texture only
  11565.   }
  11566.  }
  11567. Transformations may also be independently applied to pigment
  11568. patterns and surface normal patterns. Note that scaling a normal
  11569. pattern affects only the width and spacing. It does not affect
  11570. the apparent height or depth of the bumps. For example:
  11571.  
  11572.  box { <0, 0, 0>, <1, 1, 1>
  11573.   texture {
  11574.    pigment {
  11575.     checker Red, White
  11576.     scale 0.25 // This affects only the color pattern
  11577.    }
  11578.    normal {
  11579.     bumps 0.3 // This specifies apparent height of bumps
  11580.     scale 0.2 // Scales diameter and space between bumps
  11581.           // but not the height. Has no effect on
  11582.           // color pattern.
  11583.    }
  11584.    rotate y*45 // This affects the entire texture but
  11585.   }       // not the object.
  11586.  }
  11587.  
  11588. 4.4  Camera
  11589. The camera definition describes the position, projection type and
  11590. properties of the camera viewing the scene. Its syntax is:
  11591.  
  11592. CAMERA:
  11593.   camera{ [CAMERA_ITEMS...] }
  11594. CAMERA_ITEM:
  11595.   CAMERA_TYPE   |   CAMERA_VECTOR   |   CAMERA_MODIFIER   |
  11596.   CAMERA_IDENTIFIER
  11597. CAMERA_TYPE:
  11598.   perspective   |   orthographic   |   fisheye   |
  11599.   ultra_wide_angle   |
  11600.   omnimax   |   panoramic   |   cylinder CylinderType
  11601. CAMERA_VECTOR:
  11602.   location <Location>   |   right <Right>   |   up <Up>   |
  11603.   direction <Direction>   |
  11604.   sky <Sky>
  11605. CAMERA_MODIFIER:
  11606.   angle Degrees   |   look_at <Look_At>   |
  11607.   blur_samples Num_of_Samples   |   aperture Size   |
  11608.   focal_point <Point>   |
  11609.   confidence Blur_Confidence   |   varience Blur_Varience   |
  11610.   NORMAL   |
  11611.   TRANSFORMATION
  11612. Depending on the projection type some of the parameters are
  11613. required, some are optional and some aren't used. If no
  11614. projection type is given the perspective camera will be used
  11615. (pinhole camera). If no camera is specified a default camera is
  11616. used.  CAMERA_ITEMs may legally appear in any order but the order
  11617. of some items is critical to the proper functioning of the
  11618. camera.  Follow the guidelines in this document closely because
  11619. POV-Ray will not stop you from making mistakes.
  11620.  
  11621.  
  11622. 4.4.1     Placing the Camera
  11623. The POV-Ray camera has ten different models, each of which uses a
  11624. different projection method to project the scene onto your
  11625. screen.  Regardless of the projection type all cameras use the
  11626. location, right, up, direction, and keywords to determine the
  11627. location and orientation of the camera. The type keywords and
  11628. these four vectors fully define the camera.  All other camera
  11629. modifiers adjust how the camera does its job.  The meaning of
  11630. these vectors and other modifiers differ with the projection type
  11631. used. A more detailed explanation of the camera types follows
  11632. later.  In the sub-sections which follows, we explain how to
  11633. place and orient the camera by the use of these four vectors and
  11634. the sky and look_at modifiers.  You may wish to refer to the
  11635. illustration of the perspective camera below as you read about
  11636. these vectors.
  11637.  
  11638.  
  11639.  
  11640.                                 
  11641.                      The perspective camera.
  11642.  
  11643. 4.4.1.1   Location and Look_At
  11644. Under many circumstances just two vectors in the camera statement
  11645. are all you need to position the camera: location and look_at
  11646. vectors. For example:
  11647.  
  11648.  camera {
  11649.   location <3,5,-10>
  11650.   look_at <0,2,1>
  11651.  }
  11652. The location is simply the x, y, z coordinates of the camera. The
  11653. camera can be located anywhere in the ray-tracing universe. The
  11654. default location is <0,0,0>. The look_at vector tells POV-Ray to
  11655. pan and tilt the camera until it is looking at the specified x,
  11656. y, z coordinates. By default the camera looks at a point one unit
  11657. in the z-direction from the location.
  11658.  
  11659. The look_at modifier should almost always be the last item in the
  11660. camera statement. If other camera items are placed after the
  11661. look_at vector then the camera may not continue to look at the
  11662. specified point.
  11663.  
  11664.  
  11665. 4.4.1.2   The Sky Vector
  11666. Normally POV-Ray pans left or right by rotating about the y-axis
  11667. until it lines up with the look_at point and then tilts straight
  11668. up or down until the point is met exactly. However you may want
  11669. to slant the camera sideways like an airplane making a banked
  11670. turn. You may change the tilt of the camera using the sky vector.
  11671. For example:
  11672.  
  11673.  camera {
  11674.   location <3,5,-10>
  11675.   sky   <1,1,0>
  11676.   look_at <0,2,1>
  11677.  }
  11678. This tells POV-Ray to roll the camera until the top of the camera
  11679. is in line with the sky vector. Imagine that the sky vector is an
  11680. antenna pointing out of the top of the camera. Then it uses the
  11681. sky vector as the axis of rotation left or right and then to tilt
  11682. up or down in line with the sky until pointing at the look_at
  11683. point. In effect you're telling POV-Ray to assume that the sky
  11684. isn't straight up. Note that the sky vector must appear before
  11685. the look_at vector.
  11686.  
  11687. The sky vector does nothing on its own. It only modifies the way
  11688. the look_at vector turns the camera. The default value is
  11689. sky<0,1,0>.
  11690.  
  11691.  
  11692. 4.4.1.3   Angle
  11693. The angle keyword followed by a float expression specifies the
  11694. (horizontal) viewing angle in degrees of the camera used. Even
  11695. though it is possible to use the direction vector to determine
  11696. the viewing angle for the perspective camera it is much easier to
  11697. use the angle keyword.
  11698.  
  11699. When you specify the angle, POV-Ray adjusts the length of the
  11700. direction vector accordingly.  The formula used is
  11701. direction_length = 0.5 * right_length / tan(angle / 2) where
  11702. right_length is the length of the right vector.  You should
  11703. therefore specify the direction and right vectors before the
  11704. angle keyword.  The right vector is explained in the next
  11705. section.
  11706.  
  11707. There is no limitation to the viewing angle except for the
  11708. perspective projection. If you choose viewing angles larger than
  11709. 360 degrees you'll see repeated images of the scene (the way the
  11710. repetition takes place depends on the camera). This might be
  11711. useful for special effects.
  11712.  
  11713.  
  11714. 4.4.1.4   The Direction Vector
  11715. You will probably not need to explicitly specify or change the
  11716. camera direction vector but it is described here in case you do.
  11717. It tells POV-Ray the initial direction to point the camera before
  11718. moving it with the look_at or rotate vectors (the default value
  11719. is direction<0,0,1>). It may also be used to control the
  11720. (horizontal) field of view with some types of projection. The
  11721. length of the vector determines the distance of the viewing plane
  11722. from the camera's location.  A shorter direction vector gives a
  11723. wider view while a longer vector zooms in for close-ups.  In
  11724. early versions of POV-Ray, this was the only way to adjust field
  11725. of view.  However zooming should now be done using the easier to
  11726. use angle keyword.
  11727.  
  11728. If you are using the ultra_wide_angle, panoramic, or cylindrical
  11729. projection you should use a unit length direction vector to avoid
  11730. strange results.
  11731.  
  11732. The length of the direction vector doesn't matter when using the
  11733. orthographic, fisheye, or omnimax projection types.
  11734.  
  11735.  
  11736. 4.4.1.5   Up and Right Vectors
  11737. The primary purpose of the up and right vectors is to tell POV-
  11738. Ray the relative height and width of the view screen. The default
  11739. values are:
  11740.  
  11741.  right 4/3*x
  11742.  up y
  11743. In the default perspective camera, these two vectors also define
  11744. the initial plane of the view screen before moving it with the
  11745. look_at or rotate vectors.  The length of the right vector
  11746. (together with the direction vector) may also be used to control
  11747. the (horizontal) field of view with some types of projection.
  11748. The look_at modifier changes both up and right so you should
  11749. always specify them before look_at.  Also the angle calculation
  11750. depends on the right vector so right should precede it.
  11751.  
  11752. Most camera types treat the up and right vectors the same as the
  11753. perspective type.  However several make special use of them.  In
  11754. the orthographic projection: The lengths of the up and right
  11755. vectors set the size of the viewing window regardless of the
  11756. direction vector length, which is not used by the orthographic
  11757. camera.
  11758.  
  11759. When using cylindrical projection: types 1 and 3, the axis of the
  11760. cylinder lies along the up vector and the width is determined by
  11761. the length of right vector or it may be overridden with the angle
  11762. vector. In type 3 the up vector determines how many units high
  11763. the image is. For example if you have up 4*y on a camera at the
  11764. origin. Only points from y=2 to y=-2 are visible. All viewing
  11765. rays are perpendicular to the y-axis. For type 2 and 4, the
  11766. cylinder lies along the right vector. Viewing rays for type 4 are
  11767. perpendicular to the right vector.
  11768.  
  11769. Note that the up, right, and direction vectors should always
  11770. remain perpendicular to each other or the image will be
  11771. distorted. If this is not the case a warning message will be
  11772. printed. The vista buffer will not work for non-perpendicular
  11773. camera vectors.  If you specify the 3 vectors as initially
  11774. perpendicular and do not explicitly re-specify the after any
  11775. look_at or rotate vectors, the everything will work fine.
  11776.  
  11777.  
  11778. 4.4.1.5.1 Aspect Ratio
  11779. Together the up and right vectors define the aspect ratio (height
  11780. to width ratio) of the resulting image. The default values
  11781. up<0,1,0> and right<1.33,0,0> result in an aspect ratio of 4 to
  11782. 3. This is the aspect ratio of a typical computer monitor. If you
  11783. wanted a tall skinny image or a short wide panoramic image or a
  11784. perfectly square image you should adjust the up and right vectors
  11785. to the appropriate proportions.
  11786.  
  11787. Most computer video modes and graphics printers use perfectly
  11788. square pixels. For example Macintosh displays and IBM SVGA modes
  11789. 640x480, 800x600 and 1024x768 all use square pixels. When your
  11790. intended viewing method uses square pixels then the width and
  11791. height you set with the Width and Height options or +W or +H
  11792. switches should also have the same ratio as the up and right
  11793. vectors. Note that 640/480 = 4/3 so the ratio is proper for this
  11794. square pixel mode.
  11795.  
  11796. Not all display modes use square pixels however. For example IBM
  11797. VGA mode 320x200 and Amiga 320x400 modes do not use square
  11798. pixels. These two modes still produce a 4/3 aspect ratio image.
  11799. Therefore images intended to be viewed on such hardware should
  11800. still use 4/3 ratio on their up and right vectors but the pixel
  11801. settings will not be 4/3.
  11802.  
  11803. For example:
  11804.  
  11805.  camera {
  11806.   location <3,5,-10>
  11807.   up    <0,1,0>
  11808.   right  <1,0,0>
  11809.   look_at <0,2,1>
  11810.  }
  11811. This specifies a perfectly square image. On a square pixel
  11812. display like SVGA you would use pixel settings such as +W480
  11813. +H480 or +W600 +H600. However on the non-square pixel Amiga
  11814. 320x400 mode you would want to use values of +W240 +H400 to
  11815. render a square image.
  11816.  
  11817. The bottom line issue is this: the up and right vectors should
  11818. specify the artist's intended aspect ratio for the image and the
  11819. pixel settings should be adjusted to that same ratio for square
  11820. pixels and to an adjusted pixel resolution for non-square pixels.
  11821. The up and right vectors should not be adjusted based on non-
  11822. square pixels.
  11823.  
  11824.  
  11825. 4.4.1.5.2 Handedness
  11826. The right vector also describes the direction to the right of the
  11827. camera. It tells POV-Ray where the right side of your screen is.
  11828. The sign of the right vector can be used to determine the
  11829. handedness of the coordinate system in use. The default value is:
  11830. right<1.33,0,0>.  This means that the +x-direction is to the
  11831. right. It is called a left-handed system because you can use your
  11832. left hand to keep track of the axes. Hold out your left hand with
  11833. your palm facing to your right. Stick your thumb up. Point
  11834. straight ahead with your index finger. Point your other fingers
  11835. to the right. Your bent fingers are pointing to the +x-direction.
  11836. Your thumb now points into +y-direction. Your index finger points
  11837. into the +z-direction.
  11838.  
  11839. To use a right-handed coordinate system, as is popular in some
  11840. CAD programs and other ray-tracers, make the same shape using
  11841. your right hand. Your thumb still points up in the +y-direction
  11842. and your index finger still points forward in the +z-direction
  11843. but your other fingers now say the +x-direction is to the left.
  11844. That means that the right side of your screen is now in the -x-
  11845. direction. To tell POV-Ray to act like this you can use a
  11846. negative x value in the right vector such as: right<-1.33,0,0>.
  11847. Since having x values increasing to the left doesn't make much
  11848. sense on a 2D screen you now rotate the whole thing 180 degrees
  11849. around by using a positive z value in your camera's location. You
  11850. end up with something like this.
  11851.  
  11852.  camera {
  11853.   location <0,0,10>
  11854.   up    <0,1,0>
  11855.   right  <-1.33,0,0>
  11856.   look_at <0,0,0>
  11857.  }
  11858. Now when you do your ray-tracer's aerobics, as explained in the
  11859. section "Understanding POV-Ray's Coordinate System", you use your
  11860. right hand to determine the direction of rotations.
  11861.  
  11862. In a two dimensional grid, x is always to the right and y is up.
  11863. The two versions of handedness arise from the question of whether
  11864. z points into the screen or out of it and which axis in your
  11865. computer model relates to up in the real world.
  11866.  
  11867. Architectural CAD systems, like AutoCAD, tend to use the God's
  11868. Eye orientation that the z-axis is the elevation and is the
  11869. model's up direction. This approach makes sense if you're an
  11870. architect looking at a building blueprint on a computer screen. z
  11871. means up, and it increases towards you, with x and y still across
  11872. and up the screen. This is the basic right handed system.
  11873.  
  11874. Stand alone rendering systems, like POV-Ray, tend to consider you
  11875. as a participant. You're looking at the screen as if you were a
  11876. photographer standing in the scene. The up direction in the model
  11877. is now y, the same as up in the real world and x is still to the
  11878. right, so z must be depth, which increases away from you into the
  11879. screen. This is the basic left handed system.
  11880.  
  11881.  
  11882. 4.4.1.6   Transforming the Camera
  11883. The various transformations such as translate and rotate
  11884. modifiers can re-position the camera once you've defined it. For
  11885. example:
  11886.  
  11887.  camera {
  11888.   location < 0, 0, 0>
  11889.   direction < 0, 0, 1>
  11890.   up    < 0, 1, 0>
  11891.   right   < 1, 0, 0>
  11892.   rotate  <30, 60, 30>
  11893.   translate < 5, 3, 4>
  11894.  }
  11895. In this example, the camera is created, then rotated by 30
  11896. degrees about the x-axis, 60 degrees about the y-axis and 30
  11897. degrees about the z-axis, then translated to another point in
  11898. space.
  11899.  
  11900.  
  11901. 4.4.2     Types of Projection
  11902. The following list explains the different projection types that
  11903. can be used with the camera. The most common types are the
  11904. perspective and orthographic projections.  In general the
  11905. CAMERA_TYPE should be the first item in a camera statement.  If
  11906. none is specified, the perspective camera is the default.
  11907.  
  11908. Perspective projection: The perspective specifies the default
  11909. perspective camera which simulates the classic pinhole camera.
  11910. The (horizontal) viewing angle is either determined by the ratio
  11911. between the length of the direction vector and the length of the
  11912. right vector or by the optional keyword angle, which is the
  11913. preferred way. The viewing angle has to be larger than 0 degrees
  11914. and smaller than 180 degrees. See the figure in "Placing the
  11915. Camera" for the geometry of the perspective camera.
  11916.  
  11917. Orthographic projection: This projection uses parallel camera
  11918. rays to create an image of the scene. The size of the image is
  11919. determined by the lengths of the right and up vectors.
  11920.  
  11921. If you add the orthographic keyword after all other parameters of
  11922. a perspective camera you'll get an orthographic view with the
  11923. same image area, i.e. the size of the image is the same. In this
  11924. case you needn't specify the lengths of the right and up vector
  11925. because they'll be calculated automatically. You should be aware
  11926. though that the visible parts of the scene change when switching
  11927. from perspective to orthographic view. As long as all objects of
  11928. interest are near the look_at point they'll be still visible if
  11929. the orthographic camera is used. Objects farther away may get out
  11930. of view while nearer objects will stay in view.
  11931.  
  11932. Fisheye projection: This is a spherical projection. The viewing
  11933. angle is specified by the angle keyword. An angle of 180 degrees
  11934. creates the "standard" fisheye while an angle of 360 degrees
  11935. creates a super-fisheye ("I-see-everything-view"). If you use
  11936. this projection you should get a circular image. If this isn't
  11937. the case, i.e. you get an elliptical image, you should read
  11938. "Aspect Ratio".
  11939.  
  11940. Ultra wide angle projection: This projection is somewhat similar
  11941. to the fisheye but it projects the image onto a rectangle instead
  11942. of a circle. The viewing angle can be specified using the angle
  11943. keyword.
  11944.  
  11945. Omnimax projection: The omnimax projection is a 180 degrees
  11946. fisheye that has a reduced viewing angle in the vertical
  11947. direction. In reality this projection is used to make movies that
  11948. can be viewed in the dome-like Omnimax theaters. The image will
  11949. look somewhat elliptical. The angle keyword isn't used with this
  11950. projection.
  11951.  
  11952. Panoramic projection: This projection is called "cylindrical
  11953. equirectangular projection". It overcomes the degeneration
  11954. problem of the perspective projection if the viewing angle
  11955. approaches 180 degrees. It uses a type of cylindrical projection
  11956. to be able to use viewing angles larger than 180 degrees with a
  11957. tolerable lateral-stretching distortion. The angle keyword is
  11958. used to determine the viewing angle.
  11959.  
  11960. Cylindrical projection: Using this projection the scene is
  11961. projected onto a cylinder. There are four different types of
  11962. cylindrical projections depending on the orientation of the
  11963. cylinder and the position of the viewpoint. A float value in the
  11964. range 1 to 4 must follow the cylinder keyword.  The viewing angle
  11965. and the length of the up or right vector determine the dimensions
  11966. of the camera and the visible image. The camera to use is
  11967. specified by a number. The types are:
  11968. 1 vertical cylinder, fixed viewpoint
  11969. 2 horizontal cylinder, fixed
  11970.   viewpoint
  11971. 3 vertical cylinder, viewpoint moves
  11972.   along the cylinder's axis
  11973. 4 horizontal cylinder, viewpoint
  11974.   moves along the cylinder's axis
  11975. You should note that the vista buffer can only be used with the
  11976. perspective and orthographic camera.
  11977.  
  11978.  
  11979. 4.4.3     Focal Blur
  11980. POV-Ray can simulate focal depth-of-field by shooting a number of
  11981. sample rays from jittered points within each pixel and averaging
  11982. the results.
  11983.  
  11984. To turn on focal blur, you must specify the aperture keyword
  11985. followed by a float value which determines the depth of the
  11986. sharpness zone. Large apertures give a lot of blurring, while
  11987. narrow apertures will give a wide zone of sharpness. Note that,
  11988. while this behaves as a real camera does, the values for aperture
  11989. are purely arbitrary and are not related to f-stops.
  11990.  
  11991. You must also specify the blur_samples keyword followed by an
  11992. integer value specifying the maximum number of rays to use for
  11993. each pixel. More rays give a smoother appearance but is slower.
  11994. By default no focal blur is used, i. e. the default aperture is 0
  11995. and the default number of samples is 0.
  11996.  
  11997. The center of the zone of sharpness is specified by the
  11998. focal_point vector.  Objects close to this point are in focus and
  11999. those farther from that point are more blurred.  The default
  12000. value is focal_point<0,0,0>.
  12001.  
  12002. Although blur_samples specifies the maximum number of samples,
  12003. there is an adaptive mechanism that stops shooting rays when a
  12004. certain degree of confidence has been reached.  At that point,
  12005. shooting more rays would not result in a significant change.  The
  12006. confidence and variance keywords are followed by float values to
  12007. control the adaptive function. The confidence value is used to
  12008. determine when the samples seem to be close enough to the correct
  12009. color. The variance value specifies an acceptable tolerance on
  12010. the variance of the samples taken so far. In other words, the
  12011. process of shooting sample rays is terminated when the estimated
  12012. color value is very likely (as controlled by the confidence
  12013. probability) near the real color value.
  12014.  
  12015. Since the confidence is a probability its values can range from 0
  12016. to 1 (the default is 0.9, i. e. 90%). The value for the variance
  12017. should be in the range of the smallest displayable color
  12018. difference (the default is 1/128).
  12019.  
  12020. Larger confidence values will lead to more samples, slower traces
  12021. and better images. The same holds for smaller variance
  12022. thresholds.
  12023.  
  12024.  
  12025. 4.4.4     Camera Ray Perturbation
  12026. The optional normal may be used to assign a normal pattern to the
  12027. camera.  For example:
  12028.  
  12029.  camera{
  12030.    location Here
  12031.    look_at There
  12032.    normal{bumps 0.5}
  12033.  }
  12034. All camera rays will be perturbed using this pattern. The image
  12035. will be distorted as though you were looking through bumpy glass
  12036. or seeing a reflection off of a bumpy surface.  This lets you
  12037. create special effects. See the animated scene camera2.pov for an
  12038. example.  See "Normal" for information on normal patterns.
  12039.  
  12040.  
  12041. 4.4.5     Camera Identifiers
  12042. Camera identifiers may be declared to make scene files more
  12043. readable and to parameterize scenes so that changing a single
  12044. declaration changes many values. You may declare several camera
  12045. identifiers if you wish. This makes it easy to quickly change
  12046. cameras. An identifier is declared as follows.
  12047.  
  12048. CAMERA_DECLARATION:
  12049.   #declare IDENTIFIER = CAMERA  |
  12050.   #local IDENTIFIER = CAMERA
  12051. Where IDENTIFIER is the name of the identifier up to 40
  12052. characters long and CAMERA is any valid camera statement. See
  12053. "#declare vs. #local" for information on identifier scope.  Here
  12054. is an example...
  12055.  
  12056.  #declare Long_Lens =
  12057.   camera {
  12058.    location -z*100
  12059.    angle 3
  12060.   }
  12061.  #declare Short_Lens =
  12062.   camera {
  12063.    location -z*50
  12064.    angle 15
  12065.   }
  12066.  camera {
  12067.   Long_Lens  // edit this line to change lenses
  12068.   look_at Here
  12069.  }
  12070.  
  12071. 4.5  Objects
  12072. Objects are the building blocks of your scene. There are a lot of
  12073. different types of objects supported by POV-Ray.  In the sections
  12074. which follow, we describe "Finite Solid Primitives", "Finite
  12075. Patch Primitives", "Infinite Solid Primitives", and "Light
  12076. Sources". These primitive shapes may be combined into complex
  12077. shapes using "Constructive Solid Geometry" or CSG.
  12078.  
  12079. The basic syntax of an object is a keyword describing its type,
  12080. some floats, vectors or other parameters which further define its
  12081. location and/or shape and some optional object modifiers such as
  12082. texture, pigment, normal, finish, interior, bounding, clipping or
  12083. transformations.  Specifically the syntax is:
  12084.  
  12085. OBJECT:
  12086.   FINITE_SOLID_OBJECT   |   FINITE_PATCH_OBJECT   |
  12087.   INFINITE_SOLID_OBJECT   |   CSG_OBJECT   |   LIGHT_SOURCE   |
  12088.   object { OBJECT_IDENTIFIER  [OBJECT_MODIFIERS...] }
  12089. FINITE_SOLID_OBJECT:
  12090.   BLOB   |   BOX   |   CONE   |   CYLINDER   |   HEIGHT_FIELD
  12091.   |   JULIA_FRACTAL   |
  12092.   LATHE   |   PRISM   |   SPHERE   |   SUPERELLIPSOID   |   SOR
  12093.   |   TEXT   |   TORUS
  12094. FINITE_PATCH_OBJECT:
  12095.   BICUBIC_PATCH   |   DISC   |   MESH   |   POLYGON   |
  12096.   TRIANGLE   |   SMOOTH_TRIANGLE
  12097. INFINITE_SOLID_OBJECT:
  12098.   PLANE   |   POLY   |   CUBIC   |   QUARTIC   |   QUADRIC
  12099. CSG_OBJECT:
  12100.   UNION   |   INTERSECTION   |   DIFFERENCE   |   MERGE
  12101. Object identifiers may be declared to make scene files more
  12102. readable and to parameterize scenes so that changing a single
  12103. declaration changes many values. An identifier is declared as
  12104. follows.
  12105.  
  12106. OBJECT_DECLARATION:
  12107.   #declare IDENTIFIER = OBJECT   |
  12108.   #local IDENTIFIER = OBJECT
  12109. Where IDENTIFIER is the name of the identifier up to 40
  12110. characters long and OBJECT is any valid object.  Note that to
  12111. invoke an object identifier, you wrap it in an object{...}
  12112. statement.  You use the object statement regardless of what type
  12113. of object it originally was.  Although early versions of POV-Ray
  12114. required this object wrapper all of the time, now it is only used
  12115. with OBJECT_IDENTIFIERS.
  12116.  
  12117. Object modifiers are covered in detail later.  However here is a
  12118. brief overview.
  12119.  
  12120. The texture describes the surface properties of the object.
  12121. Complete details are in "Textures".  Textures are combinations of
  12122. pigments, normals, and finishes. In the section "Pigment" you'll
  12123. learn how to specify the color or pattern of colors inherent in
  12124. the. In "Normal" we describe a method of simulating various
  12125. patterns of bumps, dents, ripples or waves by modifying the
  12126. surface normal vector. The section on "Finish" describes the
  12127. reflective properties of the surface.  The "Interior" is a new
  12128. feature in POV-Ray 3.1.  It contains information about the
  12129. interior of the object which was formerly contained in the finish
  12130. and halo parts of a texture.  Interior items are no longer part
  12131. of the texture.  Instead, they attach directly to the objects.
  12132. The halo feature has been discontinued and replaced with a new
  12133. feature called "Media" which replaces both halo and atmosphere.
  12134.  
  12135. Bounding shapes are finite, invisible shapes which wrap around
  12136. complex, slow rendering shapes in order to speed up rendering
  12137. time. Clipping shapes are used to cut away parts of shapes to
  12138. expose a hollow interior. Transformations tell the ray-tracer how
  12139. to move, size or rotate the shape and/or the texture in the
  12140. scene.
  12141.  
  12142.  
  12143. 4.5.1     Finite Solid Primitives
  12144. There are thirteen different solid finite primitive shapes: blob,
  12145. box, cone, cylinder, height field, Julia fractal, lathe, prisms,
  12146. sphere, superellipsoid, surface of revolution, text object and
  12147. torus. These have a well-defined inside and can be used in CSG
  12148. (see section "Constructive Solid Geometry"). They are finite and
  12149. respond to automatic bounding.  You may specify an interior for
  12150. these objects.
  12151.  
  12152.  
  12153. 4.5.1.1   Blob
  12154. Blobs are an interesting and flexible object type. Mathematically
  12155. they are iso-surfaces of scalar fields, i.e. their surface is
  12156. defined by the strength of the field in each point. If this
  12157. strength is equal to a threshold value you're on the surface
  12158. otherwise you're not.
  12159.  
  12160. Picture each blob component as an object floating in space. This
  12161. object is filled with a field that has its maximum at the center
  12162. of the object and drops off to zero at the object's surface. The
  12163. field strength of all those components are added together to form
  12164. the field of the blob. Now POV-Ray looks for points where this
  12165. field has a given value, the threshold value. All these points
  12166. form the surface of the blob object. Points with a greater field
  12167. value than the threshold value are considered to be inside while
  12168. points with a smaller field value are outside.
  12169.  
  12170. There's another, simpler way of looking at blobs. They can be
  12171. seen as a union of flexible components that attract or repel each
  12172. other to form a blobby organic looking shape. The components'
  12173. surfaces actually stretch out smoothly and connect as if they
  12174. were made of honey or something like that.
  12175.  
  12176. The syntax for blob is defined as follows:
  12177.  
  12178. BLOB:
  12179.   blob { BLOB_ITEM... [BLOB_MODIFIERS...]}
  12180. BLOB_ITEM:
  12181.   sphere{<Center>, Radius, [ strength ] Strength
  12182.   [COMPONENT_MODIFIER...] }   |
  12183.   cylinder{<End1>, <End2>, Radius, [ strength ] Strength
  12184.   [COMPONENT_MODIFIER...] }   |
  12185.   component Strength, Radius, <Center>   |
  12186.   threshold Amount
  12187. COMPONENT_MODIFIER:
  12188.   TEXTURE   |   PIGMENT   |   NORMAL   |   FINISH   |
  12189.   TRANSFORMATION
  12190. BLOB_MODIFIER:
  12191.   hierarchy [Boolean]   |
  12192.   sturm [Boolean]   |
  12193.   OBJECT_MODIFIER
  12194. The threshold keyword is followed by a float value which
  12195. determines the total field strength value that POV-Ray is looking
  12196. for. The default value if none is specified is threshold 1.0.  By
  12197. following the ray out into space and looking at how each blob
  12198. component affects the ray, POV-Ray will find the points in space
  12199. where the field strength is equal to the threshold value. The
  12200. following list shows some things you should know about the
  12201. threshold value.
  12202.  
  12203. 1) The threshold value must be positive.
  12204. 2) A component disappears if the threshold value is greater than
  12205.   its strength.
  12206. 3) As the threshold value gets larger, the surface you see gets
  12207.   closer to the centers of the components.
  12208. 4) As the threshold value gets smaller, the surface you see gets
  12209.   closer to the surface of the components.
  12210. Cylindrical components are specified by a cylinder statement.
  12211. The center of the end-caps of the cylinder is defined by the
  12212. vectors <End1> and <End2>.  Next is the float value of the Radius
  12213. followed by the float Strength.  These vectors and floats are
  12214. required and should be separated by commas.  The keyword strength
  12215. may optionally precede the strength value. The cylinder has
  12216. hemispherical caps at each end.
  12217.  
  12218. Spherical components are specified by a sphere statement.  The
  12219. location is defined by the vector <Center>.  Next is the float
  12220. value of the Radius followed by the float Strength.  These vector
  12221. and float values are required and should be separated by commas.
  12222. The keyword strength may optionally precede the strength value.
  12223.  
  12224. You usually will apply a single texture to the entire blob
  12225. object, and you typically use transformations to change its size,
  12226. location, and orientation.  However both the cylinder and sphere
  12227. statements may have individual texture, pigment, normal, finish,
  12228. and transformations applied to them.  You may not apply separate
  12229. interior statements to the components but you may specify one for
  12230. the entire blob.  Note that by unevenly scaling a spherical
  12231. component you can create ellipsoidal components. The tutorial
  12232. section on "Blob Object" illustrates individually textured blob
  12233. components and many other blob examples.
  12234.  
  12235. The component keyword is an obsolete method for specifying a
  12236. spherical component and is only used for compatibility with
  12237. earlier POV-Ray versions.  It may not have textures or
  12238. transformations individually applied to it.
  12239.  
  12240. The strength parameter of either type of blob component is a
  12241. float value specifying the field strength at the center of the
  12242. object. The strength may be positive or negative. A positive
  12243. value will make that component attract other components while a
  12244. negative value will make it repel other components. Components in
  12245. different, separate blob shapes do not affect each other.
  12246.  
  12247. You should keep the following things in mind.
  12248.  
  12249. 1) The strength value may be positive or negative. Zero is a bad
  12250.   value, as the net result is that no field was added --- you
  12251.   might just as well have not used this component.
  12252. 2) If strength is positive, then POV-Ray will add the component's
  12253.   field to the space around the center of the component. If this
  12254.   adds enough field strength to be greater than the threshold
  12255.   value you will see a surface.
  12256. 3) If the strength value is negative, then POV-Ray will subtract
  12257.   the component's field from the space around the center of the
  12258.   component. This will only do something if there happen to be
  12259.   positive components nearby. What happens is that the surface
  12260.   around any nearby positive components will be dented away from
  12261.   the center of the negative component.
  12262. After all components and the optional threshold value have been
  12263. specified you may specify zero or more blob modifiers. A blob
  12264. modifier is any regular object modifier or the hierarchy or sturm
  12265. keywords.
  12266.  
  12267. The components of each blob object are internally bounded by a
  12268. spherical bounding hierarchy to speed up blob intersection tests
  12269. and other operations. By using the optional keyword hierarchy
  12270. followed by an optional boolean float value to turn it off or on.
  12271. By default it is on.
  12272.  
  12273. The calculations for blobs must be very accurate. If this shape
  12274. renders improperly you may add the keyword sturm followed by an
  12275. optional boolean float value to turn it off or on POV-Ray's
  12276. slower-yet-more-accurate Sturmian root solver. By default it is
  12277. off.
  12278.  
  12279. An example of a three component blob is:
  12280.  
  12281.  blob {
  12282.   threshold 0.6
  12283.   sphere { <.75, 0, 0>, 1, 1 }
  12284.   sphere { <-.375, .64952, 0>, 1, 1 }
  12285.   sphere { <-.375, -.64952, 0>, 1, 1 }
  12286.   scale 2
  12287.  }
  12288. If you have a single blob component then the surface you see will
  12289. just look like the object used, i.e. a sphere or a cylinder, with
  12290. the surface being somewhere inside the surface specified for the
  12291. component. The exact surface location can be determined from the
  12292. blob equation listed below (you will probably never need to know
  12293. this, blobs are more for visual appeal than for exact modeling).
  12294.  
  12295. For the more mathematically minded, here's the formula used
  12296. internally by POV-Ray to create blobs. You don't need to
  12297. understand this to use blobs. The density of the blob field of a
  12298. single component is:
  12299.  
  12300.                                 
  12301. where distance is the distance of a given point from the
  12302. spherical blob's center or cylinder blob's axis.  This formula
  12303. has the nice property that it is exactly equal to the strength
  12304. parameter at the center of the component and drops off to exactly
  12305. 0 at a distance from the center of the component that is equal to
  12306. the radius value. The density formula for more than one blob
  12307. component is just the sum of the individual component densities.
  12308.  
  12309.  
  12310. 4.5.1.2   Box
  12311. A simple box can be defined by listing two corners of the box
  12312. using the following syntax for a box statement:
  12313.  
  12314. BOX:
  12315.   box { <Corner_1>, <Corner_2> [OBJECT_MODIFIERS...]}
  12316.                                 
  12317.                      The geometry of a box.
  12318. Where <Corner_1> and <Corner_2> are vectors defining the x, y, z
  12319. coordinates of the opposite corners of the box.
  12320.  
  12321. Note that all boxes are defined with their faces parallel to the
  12322. coordinate axes. They may later be rotated to any orientation
  12323. using the rotate keyword.
  12324.  
  12325. Boxes are calculated efficiently and make good bounding shapes
  12326. (if manually bounding seems to be necessary).
  12327.  
  12328.  
  12329. 4.5.1.3   Cone
  12330. The cone statement creates a finite length cone or a frustum (a
  12331. cone with the point cut off).  The syntax is:
  12332.  
  12333. CONE:
  12334.   cone { <Base_Point>, Base_Radius, <Cap_Point>, Cap_Radius
  12335.      [ open ][OBJECT_MODIFIERS...]
  12336.   }
  12337.                                 
  12338.                      The geometry of a cone.
  12339. Where <Base_Point> and < Cap_Point> are vectors defining the x,
  12340. y, z coordinates of the center of the cone's base and cap and
  12341. Base_Radius and Cap_Radius are float values for the corresponding
  12342. radii.
  12343.  
  12344. Normally the ends of a cone are closed by flat planes which are
  12345. parallel to each other and perpendicular to the length of the
  12346. cone. Adding the optional keyword open after Cap_Radius will
  12347. remove the end caps and results in a tapered hollow tube like a
  12348. megaphone or funnel.
  12349.  
  12350.  
  12351. 4.5.1.4   Cylinder
  12352. The cylinder statement creates finite length cylinder with
  12353. parallel end caps The syntax is:
  12354.  
  12355. CYLINDER:
  12356.   cylinder{ <Base_Point>, <Cap_Point>, Radius
  12357.      [ open ][OBJECT_MODIFIERS...]
  12358.   }
  12359.                                 
  12360.                    The geometry of a cylinder.
  12361. Where <Base_Point> and <Cap_Point> are vectors defining the x, y,
  12362. z coordinates of the cylinder's base and cap and Radius is a
  12363. float value for the radius.
  12364.  
  12365. Normally the ends of a cylinder are closed by flat planes which
  12366. are parallel to each other and perpendicular to the length of the
  12367. cylinder. Adding the optional keyword open after the radius will
  12368. remove the end caps and results in a hollow tube.
  12369.  
  12370.  
  12371. 4.5.1.5   Height Field
  12372. Height fields are fast, efficient objects that are generally used
  12373. to create mountains or other raised surfaces out of hundreds of
  12374. triangles in a mesh. The height_field statement syntax is:
  12375.  
  12376. HEIGHT_FIELD:
  12377.   height_field{ HF_TYPE "filename" [HF_MODIFIER...] }
  12378. HF_TYPE:
  12379.   gif   |   tga   |   pot   |   png   |   pgm   |   ppm   |
  12380.   sys
  12381. HF_MODIFIER:
  12382.   hierarchy [Boolean]   |
  12383.   smooth [Boolean]   |
  12384.   water_level Level   |
  12385.   OBJECT_MODIFIER
  12386. A height field is essentially a one unit wide by one unit long
  12387. square with a mountainous surface on top. The height of the
  12388. mountain at each point is taken from the color number or palette
  12389. index of the pixels in a graphic image file. The maximum height
  12390. is one, which corresponds to the maximum possible color or
  12391. palette index value in the image file.
  12392.  
  12393.                                 
  12394.      The size and orientation of an un-scaled height field.
  12395. The mesh of triangles corresponds directly to the pixels in the
  12396. image file. Each square formed by four neighboring pixels is
  12397. divided into two triangles. An image with a resolution of N*M
  12398. pixels has (N-1)*(M-1) squares that are divided into 2*(N-1)*(M-
  12399. 1) triangles.
  12400.  
  12401.                                 
  12402.  Four pixels of an image and the resulting heights and triangles
  12403.                       in the height field.
  12404. The resolution of the height field is influenced by two factors:
  12405. the resolution of the image and the resolution of the color/index
  12406. values. The size of the image determines the resolution in the x-
  12407. and z-direction. A larger image uses more triangles and looks
  12408. smoother. The resolution of the color/index value determines the
  12409. resolution along the y-axis. A height field made from an 8 bit
  12410. image can have 256 different height levels while one made from a
  12411. 16 bit image can have up to 65536 different height levels. Thus
  12412. the second height field will look much smoother in the y-
  12413. direction if the height field is created appropriately.
  12414.  
  12415. The size/resolution of the image does not affect the size of the
  12416. height field. The un-scaled height field size will always be 1 by
  12417. 1 by 1. Higher resolution image files will create smaller
  12418. triangles, not larger height fields.
  12419.  
  12420. There are six or possibly seven types of files which can define a
  12421. height field. The image file type used to create a height field
  12422. is specified by one of the keywords gif, tga, pot, png, pgm, ppm,
  12423. and possibly sys which is a system specific (e. g. Windows BMP or
  12424. Macintosh Pict) format file. The GIF, PNG, PGM, and possibly SYS
  12425. format files are the only ones that can be created using a
  12426. standard paint program. Though there are paint programs for
  12427. creating TGA image files they won't be of much use for creating
  12428. the special 16 bit TGA files used by POV-Ray (see below and
  12429. "HF_Gray_16" for more details).
  12430.  
  12431. In an image file like GIF that uses a color palette the color
  12432. number is the palette index at a given pixel. Use a paint program
  12433. to look at the palette of a GIF image. The first color is palette
  12434. index zero, the second is index one, the third is index two and
  12435. so on. The last palette entry is index 255. Portions of the image
  12436. that use low palette entries will result in lower parts of the
  12437. height field. Portions of the image that use higher palette
  12438. entries will result in higher parts of the height field.
  12439.  
  12440. Height fields created from GIF files can only have 256 different
  12441. height levels because the maximum number of colors in a GIF file
  12442. is 256.
  12443.  
  12444. The color of the palette entry does not affect the height of the
  12445. pixel. Color entry 0 could be red, blue, black or orange but the
  12446. height of any pixel that uses color entry 0 will always be 0.
  12447. Color entry 255 could be indigo, hot pink, white or sky blue but
  12448. the height of any pixel that uses color entry 255 will always be
  12449. 1.
  12450.  
  12451. You can create height field GIF images with a paint program or a
  12452. fractal program like Fractint. You can usually get Fractint from
  12453. most of the same sources as POV-Ray.
  12454.  
  12455. A POT file is essentially a GIF file with a 16 bit palette. The
  12456. maximum number of colors in a POT file is 65536. This means a POT
  12457. height field can have up to 65536 possible height values. This
  12458. makes it possible to have much smoother height fields. Note that
  12459. the maximum height of the field is still 1 even though more
  12460. intermediate values are possible. At the time of this writing the
  12461. only program that created POT files was a freeware MS-Dos/Windows
  12462. program called Fractint. POT files generated with this fractal
  12463. program create fantastic landscapes.
  12464.  
  12465. The TGA and PPM file formats may be used as a storage device for
  12466. 16 bit numbers rather than an image file. These formats use the
  12467. red and green bytes of each pixel to store the high and low bytes
  12468. of a height value. These files are as smooth as POT files but
  12469. they must be generated with special custom-made programs. Several
  12470. programs can create TGA heightfields in the format POV uses, such
  12471. as Gforge and Terrain Maker.
  12472.  
  12473. PNG format heightfields are usually stored in the form of a
  12474. grayscale image with black corresponding to lower and white to
  12475. higher parts of the height field. Because PNG files can store up
  12476. to 16 bits in grayscale images they will be as smooth as TGA and
  12477. PPM images. Since they are grayscale images you will be able to
  12478. view them with a regular image viewer. gforge can create 16-bit
  12479. heightfields in PNG format. Color PNG images will be used in the
  12480. same way as TGA and PPM images.
  12481.  
  12482. SYS format is a platform specific file format. See your platform
  12483. specific documentation for details.
  12484.  
  12485. In addition to all the usual object modifiers, there are three
  12486. additional height field modifiers available.
  12487.  
  12488. The optional water_level parameter may be added after the file
  12489. name. It consists of the keyword water_level followed by a float
  12490. value telling the program to ignore parts of the height field
  12491. below that value. The default value is zero and legal values are
  12492. between zero and one. For example water_level 0.5 tells POV-Ray
  12493. to only render the top half of the height field. The other half
  12494. is below the water and couldn't be seen anyway. Using water_level
  12495. renders faster than cutting off the lower part using CSG or
  12496. clipping. This term comes from the popular use of height fields
  12497. to render landscapes. A height field would be used to create
  12498. islands and another shape would be used to simulate water around
  12499. the islands. A large portion of the height field would be
  12500. obscured by the water so the water_level parameter was introduced
  12501. to allow the ray-tracer to ignore the unseen parts of the height
  12502. field. water_level is also used to cut away unwanted lower values
  12503. in a height field. For example if you have an image of a fractal
  12504. on a solid colored background, where the background color is
  12505. palette entry 0, you can remove the background in the height
  12506. field by specifying, water_level 0.001.
  12507.  
  12508. Normally height fields have a rough, jagged look because they are
  12509. made of lots of flat triangles. Adding the keyword smooth causes
  12510. POV-Ray to modify the surface normal vectors of the triangles in
  12511. such a way that the lighting and shading of the triangles will
  12512. give a smooth look. This may allow you to use a lower resolution
  12513. file for your height field than would otherwise be needed.
  12514. However, smooth triangles will take longer to render.  The
  12515. default value is off.  You may optionally use a boolean value
  12516. such as smooth on or smooth off.
  12517.  
  12518. In order to speed up the intersection tests an one-level bounding
  12519. hierarchy is available. By default it is always used but it can
  12520. be switched off using hierarchy off to improve the rendering
  12521. speed for small height fields (i.e. low resolution images).  You
  12522. may optionally use a boolean value such as hierarchy on or
  12523. hierarchy off.
  12524.  
  12525.  
  12526. 4.5.1.6   Julia Fractal
  12527. A julia fractal object is a 3-D slice of a 4-D object created by
  12528. generalizing the process used to create the classic Julia sets.
  12529. You can make a wide variety of strange objects using the
  12530. julia_fractal statement including some that look like bizarre
  12531. blobs of twisted taffy. The julia_fractal syntax is:
  12532.  
  12533. JULIA_FRACTAL:
  12534.   julia_fractal{ <4D_Julia_Parameter> [JF_ITEM...]
  12535.   [OBJECT_MODIFIER...] }
  12536. JF_ITEM:
  12537.   ALGEBRA_TYPE   |   FUNCTION_TYPE   |
  12538.   max_iteration Count   |   precision Amt   |
  12539.   slice <4D_Normal>, Distance
  12540. ALGEBRA_TYPE:
  12541.   quaternion   |   hypercomplex
  12542. FUNCTION_TYPE:
  12543.   sqr   |   cube   |   exp   |   reciprocal   |   sin   |   asin
  12544.   |
  12545.   sinh   |   asinh   |   cos   |   acos   |   cosh   |   acosh
  12546.   |
  12547.   tan   |   atan   |   tanh   |   atanh   |   log   |   pwr(
  12548.   X_Val, Y_Val )
  12549. The required 4-D vector <4D_Julia_Parameter> is the classic Julia
  12550. parameter p in the iterated formula f(h) + p.
  12551.  
  12552. The julia fractal object is calculated by using an algorithm that
  12553. determines whether an arbitrary point h(0) in 4-D space is inside
  12554. or outside the object. The algorithm requires generating the
  12555. sequence of vectors h(0), h(1), ... by iterating the formula
  12556. h(n+1) = f(h(n)) + p (n = 0, 1, ..., max_iteration-1) where p is
  12557. the fixed 4-D vector parameter of the julia fractal and f() is
  12558. one of the functions sqr, cube, ... specified by the presence of
  12559. the corresponding keyword. The point h(0) that begins the
  12560. sequence is considered inside the julia fractal object if none of
  12561. the vectors in the sequence escapes a hypersphere of radius 4
  12562. about the origin before the iteration number reaches the integer
  12563. max_iteration value. As you increase max_iteration, some points
  12564. escape that did not previously escape, forming the julia fractal.
  12565. Depending on the <4D_Julia_Parameter>, the julia fractal object
  12566. is not necessarily connected; it may be scattered fractal dust.
  12567. Using a low max_iteration can fuse together the dust to make a
  12568. solid object. A high max_iteration is more accurate but slows
  12569. rendering. Even though it is not accurate, the solid shapes you
  12570. get with a low, max_iteration value can be quite interesting.  If
  12571. none is specified, the default is max_iteration 20.
  12572.  
  12573. Since the mathematical object described by this algorithm is four-
  12574. dimensional and POV-Ray renders three dimensional objects, there
  12575. must be a way to reduce the number of dimensions of the object
  12576. from four dimensions to three. This is accomplished by
  12577. intersecting the 4-D fractal with a 3-D "plane" defined by the
  12578. slice modifier and then projecting the intersection to 3-D space.
  12579. The keyword is followed by 4D vector and a float separated by a
  12580. comma.  The slice plane is the 3-D space that is perpendicular to
  12581. <4D_Normal> and is Distance units from the origin. Zero length
  12582. <4D_Normal> vectors or a  <4D_Normal> vector with a zero fourth
  12583. component are illegal.  If none is specified, the default is
  12584. slice <0,0,0,1>,0.
  12585.  
  12586. You can get a good feel for the four dimensional nature of a
  12587. julia fractal by using POV-Ray's animation feature to vary a
  12588. slice's Distance parameter. You can make the julia fractal appear
  12589. from nothing, grow, then shrink to nothing as Distancechanges,
  12590. much as the cross section of a 3-D object changes as it passes
  12591. through a plane.
  12592.  
  12593. The precision parameter is a tolerance used in the determination
  12594. of whether points are inside or outside the fractal object.
  12595. Larger values give more accurate results but slower rendering.
  12596. Use as low a value as you can without visibly degrading the
  12597. fractal object's appearance but note values less than 1.0 are
  12598. clipped at 1.0.  The default if none is specified is precision
  12599. 20.
  12600.  
  12601. The presence of the keywords quaternion or hypercomplex determine
  12602. which 4-D algebra is used to calculate the fractal. The default
  12603. is quaternion. Both are 4-D generalizations of the complex
  12604. numbers but neither satisfies all the field properties (all the
  12605. properties of real and complex numbers that many of us slept
  12606. through in high school). Quaternions have non-commutative
  12607. multiplication and hypercomplex numbers can fail to have a
  12608. multiplicative inverse for some non-zero elements (it has been
  12609. proved that you cannot successfully generalize complex numbers to
  12610. four dimensions with all the field properties intact, so
  12611. something has to break). Both of these algebras were discovered
  12612. in the 19th century. Of the two, the quaternions are much better
  12613. known, but one can argue that hypercomplex numbers are more
  12614. useful for our purposes, since complex valued functions such as
  12615. sin, cos, etc. can be generalized to work for hypercomplex
  12616. numbers in a uniform way.
  12617.  
  12618. For the mathematically curious, the algebraic properties of these
  12619. two algebras can be derived from the multiplication properties of
  12620. the unit basis vectors 1 = <1,0,0,0>, i=< 0,1,0,0>, j=<0,0,1,0>
  12621. and k=< 0,0,0,1>. In both algebras 1 x = x 1 = x for any x (1 is
  12622. the multiplicative identity). The basis vectors 1 and i behave
  12623. exactly like the familiar complex numbers 1 and i in both
  12624. algebras.
  12625. Quaternion basis vector
  12626. multiplication rules:
  12627. ij = k           jk = i    ki = j
  12628. ji = -k          kj = -i   ik = -j
  12629. ii = jj = kk = - ijk = -1  
  12630. 1
  12631.  
  12632. Hypercomplex basis vector
  12633. multiplication rules:
  12634. ij = k           jk = -i   ki = -j
  12635. ji = k           kj = -i   ik = -j
  12636. ii = jj = kk = - ijk = 1   
  12637. 1
  12638. A distance estimation calculation is used with the quaternion
  12639. calculations to speed them up. The proof that this distance
  12640. estimation formula works does not generalize from two to four
  12641. dimensions but the formula seems to work well anyway, the absence
  12642. of proof notwithstanding!
  12643.  
  12644. The presence of one of the function keywords sqr, cube, etc.
  12645. determines which function is used for f(h) in the iteration
  12646. formula h(n+1) = f(h(n)) + p. The default is sqr. Most of the
  12647. function keywords work only if the hypercomplex keyword is
  12648. present. Only sqr and cube work with quaternion. The functions
  12649. are all familiar complex functions generalized to four
  12650. dimensions.
  12651.  
  12652.  
  12653. Function Keyword  Maps 4-D
  12654. value h to:
  12655. sqr       h*h
  12656. cube      h*h*h
  12657. exp       e raised to the
  12658.           power h
  12659. reciproca 1/h
  12660. l
  12661. sin       sine of h
  12662. asin      arcsine of h
  12663. sinh      hyperbolic sine of h
  12664. asinh     inverse hyperbolic
  12665.           sine of h
  12666. cos       cosine of h
  12667. acos      arccosine of h
  12668. cosh      hyperbolic cos of h
  12669. acosh     inverse hyperbolic
  12670.           cosine of h
  12671. tan       tangent of h
  12672. atan      arctangent of h
  12673. tanh      hyperbolic tangent
  12674.           of h
  12675. atanh     inverse hyperbolic
  12676.           tangent of h
  12677. log       natural logarithm of
  12678.           h
  12679. pwr(x,y)  h raised to the
  12680.           complex power x+iy
  12681. A simple example of a julia fractal object is:
  12682.  
  12683.  julia_fractal {
  12684.   <-0.083,0.0,-0.83,-0.025>
  12685.   quaternion
  12686.   sqr
  12687.   max_iteration 8
  12688.   precision 15
  12689.  }
  12690. The first renderings of julia fractals using quaternions were
  12691. done by Alan Norton and later by John Hart in the '80's. This new
  12692. POV-Ray implementation follows Fractint in pushing beyond what is
  12693. known in the literature by using hypercomplex numbers and by
  12694. generalizing the iterating formula to use a variety of
  12695. transcendental functions instead of just the classic Mandelbrot
  12696. z2 + c formula. With an extra two dimensions and eighteen
  12697. functions to work with, intrepid explorers should be able to
  12698. locate some new fractal beasts in hyperspace, so have at it!
  12699.  
  12700.  
  12701. 4.5.1.7   Lathe
  12702. The lathe is an object generated from rotating a two-dimensional
  12703. curve about an axis. This curve is defined by a set of points
  12704. which are connected by linear, quadratic, cubic or bezier spline
  12705. curves. The syntax is:
  12706.  
  12707. LATHE:
  12708.   lathe {
  12709.        [SPLINE_TYPE]  Number_Of_Points, <Point_1> <Point_2>...
  12710.   <Point_n>
  12711.        [LATHE_MODIFIER...]
  12712.   }
  12713. SPLINE_TYPE:
  12714.   linear_spline   |   quadratic_spline   |   cubic_spline   |
  12715.   bezier_spline
  12716. LATHE_MODIFIER:
  12717.   sturm   |   OBJECT_MODIFIER
  12718. The first item is a keyword specifying the type of spline.  The
  12719. default if none is specified is linear_spline.  The required
  12720. integer value Number_Of_Points specifies how many two-dimensional
  12721. points are used to define the curve. The points follow and are
  12722. specified by 2-D vectors.  The curve is not automatically closed,
  12723. i.e. the first and last points are not automatically connected.
  12724. You will have to do this by your own if you want a closed curve.
  12725. The curve thus defined is rotated about the y-axis to form the
  12726. lathe object which is centered at the origin.
  12727.  
  12728. The following examples creates a simple lathe object that looks
  12729. like a thick cylinder, i.e. a cylinder with a thick wall:
  12730.  
  12731.  lathe {
  12732.   linear_spline
  12733.   5,
  12734.   <2, 0>, <3, 0>, <3, 5>, <2, 5>, <2, 0>
  12735.   pigment {Red}
  12736.  }
  12737. The cylinder has an inner radius of 2 and an outer radius of 3,
  12738. giving a wall width of 1. It's height is 5 and it's located at
  12739. the origin pointing up, i.e. the rotation axis is the y-axis.
  12740. Note that the first and last point are equal to get a closed
  12741. curve.
  12742.  
  12743. The splines that are used by the lathe and prism objects are a
  12744. little bit difficult to understand. The basic concept of splines
  12745. is to draw a curve through a given set of points in a determined
  12746. way. The default linear_spline is the simplest spline because
  12747. it's nothing more than connecting consecutive points with a line.
  12748. This means that the curve that is drawn between two points only
  12749. depends on those two points. No additional information is taken
  12750. into account. The other splines are different in that they do
  12751. take other points into account when connecting two points.  This
  12752. creates a smooth curve and, in the case of the cubic spline,
  12753. produces smoother transitions at each point.
  12754.  
  12755. The quadratic_spline keyword creates splines that are made of
  12756. quadratic curves. Each of them connects two consecutive points.
  12757. Since those two points (call them second and third point) are not
  12758. sufficient to describe a quadratic curve the predecessor of the
  12759. second point is taken into account when the curve is drawn.
  12760. Mathematically the relationship (their location on the 2-D plane)
  12761. between the first and second point determines the slope of the
  12762. curve at the second point. The slope of the curve at the third
  12763. point is out of control. Thus quadratic splines look much
  12764. smoother than linear splines but the transitions at each point
  12765. are generally not smooth because the slopes on both sides of the
  12766. point are different.
  12767.  
  12768. The cubic_spline keyword creates splines overcome the transition
  12769. problem of quadratic splines because they also take the fourth
  12770. point into account when drawing the curve between the second and
  12771. third point. The slope at the fourth point is under control now
  12772. and allows a smooth transition at each point. Thus cubic splines
  12773. produce the most flexible and smooth curves.
  12774.  
  12775. The bezier_spline is an alternate kind of cubic spline.  Points 1
  12776. and 4 specify the end points of a segment and points 2 and 3 are
  12777. control points which specify the slope at the endpoints. Points 2
  12778. and 3 do not actually lie on the spline.  They adjust the slope
  12779. of the spline.  If you draw an imaginary line between point 1 and
  12780. 2, it represents the slope at point 1.  It is a line tangent to
  12781. the curve at point 1.  The greater the distance between 1 and 2,
  12782. the flatter the curve.  With a short tangent the spline can bend
  12783. more.  The same holds true for control point 3 and endpoint 4.
  12784. If you want the spline to be smooth between segments, point 3 and
  12785. 4 on one segment and point 1 and 2 on the next segment must form
  12786. a straight line and point 4 of one segment must be the same as
  12787. point one on the next segment.
  12788.  
  12789. You should note that the number of spline segments, i. e. curves
  12790. between two points, depends on the spline type used. For linear
  12791. splines you get n-1 segments connecting the points P[i],
  12792. i=1,...,n. A quadratic spline gives you n-2 segments because the
  12793. last point is only used for determining the slope as explained
  12794. above (thus you'll need at least three points to define a
  12795. quadratic spline). The same holds for cubic splines where you get
  12796. n-3 segments with the first and last point used only for slope
  12797. calculations (thus needing at least four points).  The bezier
  12798. spline requires 4 points per segment.
  12799.  
  12800. If you want to get a closed quadratic and cubic spline with
  12801. smooth transitions at the end points you have to make sure that
  12802. in the cubic case P[n-1] = P[2] (to get a closed curve), P[n] =
  12803. P[3] and P[n-2] = P[1] (to smooth the transition). In the
  12804. quadratic case P[n-1] = P[1] (to close the curve) and P[n] =
  12805. P[2].
  12806.  
  12807. The sturm keyword can be used to specify that the slower but more
  12808. accurate Sturmian root solver should be used.  Use it with the
  12809. quadratic spline lathe if the shape does not render properly.
  12810. Since a quadratic polynomial has to be solved for the linear
  12811. spline lathe the Sturmian root solver is not needed. In case of
  12812. cubic or bezier splines, the Sturmian root solver is always used
  12813. because a 6th order polynomial has to be solved.
  12814.  
  12815.  
  12816. 4.5.1.8   Prism
  12817. The prism is an object generated specifying one or more two-
  12818. dimensional, closed curves in the x-z plane and sweeping them
  12819. along y axis. These curves are defined by a set of points which
  12820. are connected by linear, quadratic, cubic or bezier splines.
  12821.  
  12822. The syntax for the prism is:
  12823.  
  12824. PRISM:
  12825.   prism { [PRISM_ITEMS...] Height_1, Height_2, Number_Of_Points,
  12826.        <Point_1>, <Point_2>, ... <Point_n>
  12827.        [ open ]
  12828.        [PRISM_MODIFIERS...]
  12829.   }
  12830. PRISM_ITEM:
  12831.   linear_spline   |   quadratic_spline   |   cubic_spline   |
  12832.   bezier_spline   |
  12833.   linear_sweep   |   conic_sweep
  12834. PRISM_MODIFIER:
  12835.   sturm   |   OBJECT_MODIFIER
  12836. The first items specify the spline type and sweep type.  The
  12837. defaults if none is specified is linear_spline and conic_sweep.
  12838. This is followed by two float values Height_1 and Height_2 which
  12839. are the y coordinates of the top and bottom of the prism. This is
  12840. followed by a float value specifying the number of 2-D points you
  12841. will use to define the prism. (This includes all control points
  12842. needed for quadratic, cubic and bezier splines). This is followed
  12843. by the specified number of 2-D vectors which define the shape in
  12844. the x-z plane.
  12845.  
  12846. The interpretation of the points depends on the spline type.  The
  12847. prism object allows you to use any number of sub-prisms inside
  12848. one prism statement (they are of the same spline and sweep type).
  12849. Wherever an even number of sub-prisms overlaps a hole appears.
  12850. Note you need not have multiple sub-prisms and they need not
  12851. overlap as these examples do.
  12852.  
  12853. In the linear_spline the first point specified is the start of
  12854. the first sub-prism.  The following points are connected by
  12855. straight lines.  If you specify a value identical to the first
  12856. point, this closes the sub-prism and next point starts a new one.
  12857. When you specify the value of that sub-prism's start, then it is
  12858. closed.  Each of the sub-prisms has to be closed by repeating the
  12859. first point of a sub-prism at the end of the sub-prism's point
  12860. sequence. In this example, there are two rectangular sub-prisms
  12861. nested inside each other to create a frame.
  12862.  
  12863.  prism {
  12864.   linear_spline
  12865.   0, 1, 10,
  12866.   <0,0>, <6,0>, <6,8>, <0,8>, <0,0>,  //outer rim
  12867.   <1,1>, <5,1>, <5,7>, <1,7>, <1,1>   //inner rim
  12868.  }
  12869. The last sub-prism of a linear spline prism is automatically
  12870. closed - just like the last sub-polygon in the polygon statement
  12871. - if the first and last point of the sub-polygon's point sequence
  12872. are not the same. This make it very easy to convert between
  12873. polygons and prisms. Quadratic, cubic and bezier splines are
  12874. never automatically closed.
  12875.  
  12876. In the quadratic_spline, each sub-prism needs an additional
  12877. control point at the beginning of each sub-prisms' point sequence
  12878. to determine the slope at the start of the curve. The first point
  12879. specified is the control point which is not actually part of the
  12880. spline.  The second point is the start of the spline.  The sub-
  12881. prism ends when this second point is duplicated.  The next point
  12882. is the control point of the next sub-prism.  The point after that
  12883. is the first point of the second sub-prism.  Here is an example:
  12884.  
  12885.  prism {
  12886.   quadratic_spline
  12887.   0, 1, 12,
  12888.   <1,-1>, <0,0>, <6,0>, <6,8>, <0,8>, <0,0>,  //outer rim
  12889.       //Control is <1,-1> and <0,0> is first & last point
  12890.   <2,0>, <1,1>, <5,1>, <5,7>, <1,7>, <1,1>   //inner rim
  12891.       //Control is <2,0> and <1,1> is first & last point
  12892.  }
  12893. In the cubic_spline, each sub-prism needs two additional control
  12894. points -- one at the beginning of each sub-prisms' point sequence
  12895. to determine the slope at the start of the curve and one at the
  12896. end. The first point specified is the control point which is not
  12897. actually part of the spline.  The second point is the start of
  12898. the spline.  The sub-prism ends when this second point is
  12899. duplicated.  The next point is the control point of the end of
  12900. the first sub-prism.  Next is the beginning control point of the
  12901. next sub-prism.  The point after that is the first point of the
  12902. second sub-prism.  Here is an example:
  12903.  
  12904.  prism {
  12905.   cubic_spline
  12906.   0, 1, 14,
  12907.   <1,-1>, <0,0>, <6,0>, <6,8>, <0,8>, <0,0>, <-1,1>, //outer rim
  12908.   //First control is <1,-1> and <0,0> is first & last point
  12909.   // Last control of first spline is <-1,1>
  12910.   <2,0>, <1,1>, <5,1>, <5,7>, <1,7>, <1,1>, <0,2> //inner rim
  12911.   //First control is <2,0> and <1,1> is first & last point
  12912.   // Last control of first spline is <0,2>
  12913.  }
  12914. The bezier_spline is an alternate kind of cubic spline.  Points 1
  12915. and 4 specify the end points of a segment and points 2 and 3 are
  12916. control points which specify the slope at the endpoints. Points 2
  12917. and 3 do not actually lie on the spline.  They adjust the slope
  12918. of the spline.  If you draw an imaginary line between point 1 and
  12919. 2, it represents the slope at point 1.  It is a line tangent to
  12920. the curve at point 1.  The greater the distance between 1 and 2,
  12921. the flatter the curve.  With a short tangent the spline can bend
  12922. more.  The same holds true for control point 3 and endpoint 4.
  12923. If you want the spline to be smooth between segments, point 3 and
  12924. 4 on one segment and point 1 and 2 on the next segment must form
  12925. a straight line and point 4 of one segment must be the same as
  12926. point one on the next segment.
  12927.  
  12928. By default linear sweeping is used to create the prism, i.e. the
  12929. prism's walls are perpendicular to the x-z-plane (the size of the
  12930. curve does not change during the sweep). You can also use
  12931. conic_sweep that leads to a prism with cone-like walls by scaling
  12932. the curve down during the sweep.
  12933.  
  12934. Like cylinders the prism is normally closed. You can remove the
  12935. caps on the prism by using the open keyword. If you do so you
  12936. shouldn't use it with CSG because the results may get wrong.
  12937.  
  12938. For an explanation of the spline concept read the description of
  12939. the "Lathe" object.  Also see the tutorials on "Lathe Object" and
  12940. "Prism Object".
  12941.  
  12942. The sturm keyword specifies the slower but more accurate Sturmian
  12943. root solver which may be used with the cubic or bezier spline
  12944. prisms if the shape does not render properly. The linear and
  12945. quadratic spline prisms do not need the Sturmian root solver.
  12946.  
  12947.  
  12948. 4.5.1.9   Sphere
  12949. The syntax of the sphere object is:
  12950.  
  12951. SPHERE:
  12952.   sphere { <Center>, Radius [OBJECT_MODIFIERS...] }
  12953.                                 
  12954.                     The geometry of a sphere.
  12955. Where <Center> is a vector specifying the x, y, z coordinates of
  12956. the center of the sphere and Radius is a float value specifying
  12957. the radius. Spheres may be scaled unevenly giving an ellipsoid
  12958. shape.
  12959.  
  12960. Because spheres are highly optimized they make good bounding
  12961. shapes (if manual bounding seems to be necessary).
  12962.  
  12963.  
  12964. 4.5.1.10  Superquadric Ellipsoid
  12965. The superellipsoid object creates a shape known as a superquadric
  12966. ellipsoid object.  It is an extension of the quadric ellipsoid.
  12967. It can be used to create boxes and cylinders with round edges and
  12968. other interesting shapes. Mathematically it is given by the
  12969. equation:
  12970.  
  12971.                                 
  12972. The values of e and n, called the east-west and north-south
  12973. exponent, determine the shape of the superquadric ellipsoid. Both
  12974. have to be greater than zero. The sphere is given by e = 1 and n
  12975. = 1.
  12976.  
  12977. The syntax of the superquadric ellipsoid is:
  12978.  
  12979. SUPERELLIPSOID:
  12980.   superellipsoid{ <Value_E, Value_N>  [OBJECT_MODIFIERS...] }
  12981. The 2-D vector specifies the e and n values in the equation
  12982. above.  The object sits at the origin and occupies a space about
  12983. the size of a box{<-1,-1,-1>,<1,1,1>}.
  12984.  
  12985. Two useful objects are the rounded box and the rounded cylinder.
  12986. These are declared in the following way.
  12987.  
  12988.  #declare Rounded_Box = superellipsoid { <Round, Round> }
  12989.  #declare Rounded_Cylinder = superellipsoid { <1, Round> }
  12990. The roundedness value Round determines the roundedness of the
  12991. edges and has to be greater than zero and smaller than one. The
  12992. smaller you choose the values, the smaller and sharper the edges
  12993. will get.
  12994.  
  12995. Very small values of e and n might cause problems with the root
  12996. solver (the Sturmian root solver cannot be used).
  12997.  
  12998.  
  12999. 4.5.1.11  Surface of Revolution
  13000. The sor object is a surface of revolution generated by rotating
  13001. the graph of a function about the y-axis. This function describes
  13002. the dependence of the radius from the position on the rotation
  13003. axis. The syntax is:
  13004.  
  13005. SOR:
  13006.   sor { Number_Of_Points,
  13007.        <Point_1>, <Point_2>, ... <Point_n>
  13008.        [ open ]
  13009.        [SOR_MODIFIERS...]
  13010.    }
  13011. SOR_MODIFIER:
  13012.   sturm   |   OBJECT_MODIFIER
  13013. The float value Number_Of_Points specifies the number of 2-D
  13014. vectors which follow. The points <Point_1> through <Point_n> are
  13015. two-dimensional vectors consisting of the radius and the
  13016. corresponding height, i.e. the position on the rotation axis.
  13017. These points are smoothly connected (the curve is passing through
  13018. the specified points) and rotated about the y-axis to form the
  13019. SOR object. The first and last points are only used to determine
  13020. the slopes of the function at the start and end point. They do
  13021. not actually lie on the curve.  The function used for the SOR
  13022. object is similar to the splines used for the lathe object. The
  13023. difference is that the SOR object is less flexible because it
  13024. underlies the restrictions of any mathematical function, i.e. to
  13025. any given point y on the rotation axis belongs at most one
  13026. function value, i.e. one radius value. You can't rotate closed
  13027. curves with the SOR object.
  13028.  
  13029. The optional keyword open allows you to remove the caps on the
  13030. SOR object. If you do this you shouldn't use it with CSG anymore
  13031. because the results may be wrong.
  13032.  
  13033. The SOR object is useful for creating bottles, vases, and things
  13034. like that. A simple vase could look like this:
  13035.  
  13036.  #declare Vase = sor {
  13037.   7,
  13038.   <0.000000, 0.000000>
  13039.   <0.118143, 0.000000>
  13040.   <0.620253, 0.540084>
  13041.   <0.210970, 0.827004>
  13042.   <0.194093, 0.962025>
  13043.   <0.286920, 1.000000>
  13044.   <0.468354, 1.033755>
  13045.   open
  13046.  }
  13047. One might ask why there is any need for a SOR object if there is
  13048. already a lathe object which is much more flexible. The reason is
  13049. quite simple. The intersection test with a SOR object involves
  13050. solving a cubic polynomial while the test with a lathe object
  13051. requires to solve of a 6th order polynomial (you need a cubic
  13052. spline for the same smoothness). Since most SOR and lathe objects
  13053. will have several segments this will make a great difference in
  13054. speed. The roots of the 3rd order polynomial will also be more
  13055. accurate and easier to find.
  13056.  
  13057. The sturm keyword may be added to specify the slower but more
  13058. accurate Sturmian root solver.  It may be used with the surface
  13059. of revolution object if the shape does not render properly.
  13060.  
  13061. The following explanations are for the mathematically interested
  13062. reader who wants to know how the surface of revolution is
  13063. calculated. Though it is not necessary to read on it might help
  13064. in understanding the SOR object.
  13065.  
  13066. The function that is rotated about the y-axis to get the final
  13067. SOR object is given by
  13068.  
  13069.                                 
  13070. with radius r and height h. Since this is a cubic function in h
  13071. it has enough flexibility to allow smooth curves.
  13072.  
  13073. The curve itself is defined by a set of n points P(i), i=0...n-1,
  13074. which are interpolated using one function for every segment of
  13075. the curve. A segment j, j=1...n-3, goes from point P(j) to point
  13076. P(j+1) and uses points P(j-1) and P(j+2) to determine the slopes
  13077. at the endpoints. If there are n points we will have n-3
  13078. segments. This means that we need at least four points to get a
  13079. proper curve.
  13080.  
  13081. The coefficients A(j), B(j), C(j) and D(j) are calculated for
  13082. every segment using the equation
  13083.  
  13084.                                 
  13085. where r(j) is the radius and h(j) is the height of point P(j).
  13086.  
  13087. The figure below shows the configuration of the points P(i), the
  13088. location of segment j, and the curve that is defined by this
  13089. segment.
  13090.  
  13091.                                 
  13092.  Segment j of n-3 segments in a point configuration of n points.
  13093.    The points describe the curve of a surface of revolution.'
  13094.  
  13095. 4.5.1.12  Text
  13096. A text object creates 3-D text as an extruded block letter.
  13097. Currently only TrueType fonts are supported but the syntax allows
  13098. for other font types to be added in the future. The syntax is:
  13099.  
  13100. TEXT_OBECT:
  13101.   text { ttf "fontname.ttf" "String_of_Text" Thickness, <Offset>
  13102.   [OBJECT_MODIFIERS...] }
  13103. Where fontname.ttf is the name of the TrueType font file.  It is
  13104. a quoted string literal or string expression. The string
  13105. expression which follows is the actual text of the string object.
  13106. It too may be a quoted string literal or string expression. See
  13107. section "Strings" for more on string expressions.
  13108.  
  13109. The text will start with the origin at the lower left, front of
  13110. the first character and will extend in the +x-direction. The
  13111. baseline of the text follows the x-axis and decenders drop into
  13112. the -y-direction.  The front of the character sits in the x-y-
  13113. plane and the text is extruded in the +z-direction. The front-to-
  13114. back thickness is specified by the required value Thickness.
  13115.  
  13116. Characters are generally sized so that 1 unit of vertical spacing
  13117. is correct. The characters are about 0.5 to 0.75 units tall.
  13118.  
  13119. The horizontal spacing is handled by POV-Ray internally including
  13120. any kerning information stored in the font. The required vector
  13121. <Offset> defines any extra translation between each character.
  13122. Normally you should specify a zero for this value. Specifying
  13123. 0.1*x would put additional 0.1 units of space between each
  13124. character.  Here is an example:
  13125.  
  13126.   text { ttf "timrom.ttf" "POV-Ray 3.1" 1, 0
  13127.     pigment { Red }
  13128.   }
  13129. Only printable characters are allowed in text objects. Characters
  13130. such as return, line feed, tabs, backspace etc. are not
  13131. supported.
  13132.  
  13133.  
  13134. 4.5.1.13  Torus
  13135. A torus is a 4th order quartic polynomial shape that looks like a
  13136. donut or inner tube. Because this shape is so useful and quartics
  13137. are difficult to define, POV-Ray lets you take a short-cut and
  13138. define a torus by:
  13139.  
  13140. TORUS:
  13141.   torus { Major, Minor [TORUS_MODIFIER...] }
  13142. TORUS_MODIFIER:
  13143.   sturm   |   OBJECT_MODIFIER
  13144. where Major is a float value giving the major radius and Minor is
  13145. a float specifying the minor radius. The major radius extends
  13146. from the center of the hole to the mid-line of the rim while the
  13147. minor radius is the radius of the cross-section of the rim. The
  13148. torus is centered at the origin and lies in the x-z-plane with
  13149. the y-axis sticking through the hole.
  13150.  
  13151.                                 
  13152.                Major and minor radius of a torus.
  13153. The torus is internally bounded by two cylinders and two rings
  13154. forming a thick cylinder. With this bounding cylinder the
  13155. performance of the torus intersection test is vastly increased.
  13156. The test for a valid torus intersection, i.e. solving a 4th order
  13157. polynomial, is only performed if the bounding cylinder is hit.
  13158. Thus a lot of slow root solving calculations are avoided.
  13159.  
  13160. Calculations for all higher order polynomials must be very
  13161. accurate. If the torus renders improperly you may add the keyword
  13162. sturm to use POV-Ray's slower-yet-more-accurate Sturmian root
  13163. solver.
  13164.  
  13165.  
  13166. 4.5.2     Finite Patch Primitives
  13167. There are six totally thin, finite objects which have no well-
  13168. defined inside. They are bicubic patch, disc, smooth triangle,
  13169. triangle, polygon and mesh. They may be combined in CSG union but
  13170. cannot be use in other types of CSG (or inside a clipped_by
  13171. statement). Because these types are finite POV-Ray can use
  13172. automatic bounding on them to speed up rendering time. As with
  13173. all shapes they can be translated, rotated and scaled.
  13174.  
  13175.  
  13176. 4.5.2.1   Bicubic Patch
  13177. A bicubic_patch is a 3D curved surface created from a mesh of
  13178. triangles. POV-Ray supports a type of bicubic patch called a
  13179. Bezier patch. A bicubic patch is defined as follows:
  13180.  
  13181. BICUBIC_PATCH:
  13182.   bicubic_patch {
  13183.        PATCH_ITEMS...
  13184.        <Point_1>,<Point_2>,<Point_3>,<Point_4>,
  13185.        <Point_5>,<Point_6>,<Point_7>,<Point_8>,
  13186.        <Point_9>,<Point_10>,<Point_11>,<Point_12>,
  13187.        <Point_13>,<Point_14>,<Point_15>,<Point_16>
  13188.        [OBJECT_MODIFIERS...]
  13189.   }
  13190. PATCH_ITEMS:
  13191.   type Patch_Type   |   u_steps Num_U_Steps   |   v_steps
  13192.   Num_V_Steps   |   flatness Flatness
  13193. The keyword type is followed by a float Patch_Type which
  13194. currently must be either 0 or 1. For type 0 only the control
  13195. points are retained within POV-Ray. This means that a minimal
  13196. amount of memory is needed but POV-Ray will need to perform many
  13197. extra calculations when trying to render the patch. Type 1
  13198. preprocesses the patch into many subpatches. This results in a
  13199. significant speedup in rendering at the cost of memory.
  13200.  
  13201. The four parameters type, flatness, u_steps and v_steps may
  13202. appear in any order. All but flatness are required.  They are
  13203. followed by 16 vectors (4 rows of 4) that define the x, y, z
  13204. coordinates of the 16 control points which define the patch. The
  13205. patch touches the four corner points <Point_1>, <Point_4>,
  13206. <Point_13> and <Point_16> while the other 12 points pull and
  13207. stretch the patch into shape. The Bezier surface is enclosed by
  13208. the convex hull formed by the 16 control points, this is known as
  13209. the convex hull property.
  13210.  
  13211. The keywords u_steps and v_steps are each followed by integer
  13212. values which tell how many rows and columns of triangles are the
  13213. minimum to use to create the surface. The maximum number of
  13214. individual pieces of the patch that are tested by POV-Ray can be
  13215. calculated from the following: pieces = 2^u_steps * 2^v_steps.
  13216.  
  13217. This means that you really should keep u_steps and v_steps under
  13218. 4. Most patches look just fine with u_steps 3 and v_steps 3,
  13219. which translates to 64 subpatches (128 smooth triangles).
  13220.  
  13221. As POV-Ray processes the Bezier patch it makes a test of the
  13222. current piece of the patch to see if it is flat enough to just
  13223. pretend it is a rectangle. The statement that controls this test
  13224. is specified with the flatness keyword followed by a float.
  13225. Typical flatness values range from 0 to 1 (the lower the slower).
  13226. The default if none is specified is 0.0.
  13227.  
  13228. If the value for flatness is 0 POV-Ray will always subdivide the
  13229. patch to the extend specified by u_steps and v_steps. If flatness
  13230. is greater than 0 then every time the patch is split, POV-Ray
  13231. will check to see if there is any need to split further.
  13232.  
  13233. There are both advantages and disadvantages to using a non-zero
  13234. flatness. The advantages include:
  13235.  
  13236.   -  If the patch isn't very curved, then this will be detected
  13237.   and POV-Ray won't waste a lot of time looking at the wrong
  13238.   pieces.
  13239.   -  If the patch is only highly curved in a couple of places,
  13240.   POV-Ray will keep subdividing there and concentrate it's
  13241.   efforts on the hard part.
  13242. The biggest disadvantage is that if POV-Ray stops subdividing at
  13243. a particular level on one part of the patch and at a different
  13244. level on an adjacent part of the patch there is the potential for
  13245. cracking. This is typically visible as spots within the patch
  13246. where you can see through. How bad this appears depends very
  13247. highly on the angle at which you are viewing the patch.
  13248.  
  13249. Like triangles, the bicubic patch is not meant to be generated by
  13250. hand. These shapes should be created by a special utility. You
  13251. may be able to acquire utilities to generate these shapes from
  13252. the same source from which you obtained POV-Ray.  Here is an
  13253. example:
  13254.  
  13255.   bicubic_patch {
  13256.     type 0
  13257.     flatness 0.01
  13258.     u_steps 4
  13259.     v_steps 4
  13260.     <0, 0, 2>, <1, 0, 0>, <2, 0, 0>, <3, 0,-2>,
  13261.     <0, 1  0>, <1, 1, 0>, <2, 1, 0>, <3, 1, 0>,
  13262.     <0, 2, 0>, <1, 2, 0>, <2, 2, 0>, <3, 2, 0>,
  13263.     <0, 3, 2>, <1, 3, 0>, <2, 3, 0>, <3, 3, -2>
  13264.   }
  13265. The triangles in a POV-Ray bicubic_patch are automatically
  13266. smoothed using normal interpolation but it is up to the user (or
  13267. the user's utility program) to create control points which
  13268. smoothly stitch together groups of patches.
  13269.  
  13270.  
  13271. 4.5.2.2   Disc
  13272. Another flat, finite object available with POV-Ray is the disc.
  13273. The disc is infinitely thin, it has no thickness. If you want a
  13274. disc with true thickness you should use a very short cylinder. A
  13275. disc shape may be defined by:
  13276.  
  13277. DISC:
  13278.   disc { <Center>, <Normal>, Radius [, Hole_Radius]
  13279.   [OBJECT_MODIFIERS...] }
  13280. The vector <Center> defines the x, y, z coordinates of the center
  13281. of the disc. The <Normal> vector describes its orientation by
  13282. describing its surface normal vector. This is followed by a float
  13283. specifying the Radius. This may be optionally followed by another
  13284. float specifying the radius of a hole to be cut from the center
  13285. of the disc.
  13286.  
  13287.  
  13288. 4.5.2.3   Mesh
  13289. The mesh object can be used to efficiently store large numbers of
  13290. triangles. Its syntax is:
  13291.  
  13292. MESH:
  13293.   mesh { MESH_TRIANGLE... [MESH_MODIFIER...] }
  13294. MESH_TRIANGLE:
  13295.   triangle { <Corner_1>, <Corner_2>, <Corner_3> [MESH_TEXTURE] }
  13296.   |
  13297.   smooth_triangle {
  13298.        <Corner_1>, <Normal_1>,
  13299.        <Corner_2>, <Normal_2>,
  13300.        <Corner_3>, <Normal_3>
  13301.        [MESH_TEXTURE]
  13302.   }
  13303. MESH_TEXTURE:
  13304.   texture { TEXTURE_IDENTIFIER }
  13305. MESH_MODIFIER:
  13306.   hierarchy [ Boolean ]   |   OBJECT_MODIFIER
  13307. Any number of triangle and/or smooth_triangle statements can be
  13308. used and each of those triangles can be individually textured by
  13309. assigning a texture identifier to it. The texture has to be
  13310. declared before the mesh is parsed. It is not possible to use
  13311. texture definitions inside the triangle or smooth triangle
  13312. statements. This is a restriction that is necessary for an
  13313. efficient storage of the assigned textures.  See "Triangle and
  13314. Smooth Triangle" for more information on triangles.
  13315.  
  13316. The mesh's components are internally bounded by a bounding box
  13317. hierarchy to speed up intersection testing. The bounding
  13318. hierarchy can be turned off with the hierarchy off keyword. This
  13319. should only be done if memory is short or the mesh consists of
  13320. only a few triangles.  The default is hierarchy on.
  13321.  
  13322. Copies of a mesh object refer to the same triangle data and thus
  13323. consume very little memory. You can easily trace hundred copies
  13324. of an 10000 triangle mesh without running out of memory (assuming
  13325. the first mesh fits into memory).
  13326.  
  13327. The mesh object has two advantages over a union of triangles: it
  13328. needs less memory and it is transformed faster. The memory
  13329. requirements are reduced by efficiently storing the triangles
  13330. vertices and normals. The parsing time for transformed meshes is
  13331. reduced because only the mesh object has to be transformed and
  13332. not every single triangle as it is necessary for unions.
  13333.  
  13334. The mesh object can currently only include triangle and smooth
  13335. triangle components. That restriction may change, allowing
  13336. polygonal components, at some point in the future.
  13337.  
  13338.  
  13339. 4.5.2.4   Polygon
  13340. The polygon object is useful for creating rectangles, squares and
  13341. other planar shapes with more than three edges. Their syntax is:
  13342.  
  13343. POLYGON:
  13344.   polygon { Number_Of_Points, <Point_1> <Point_2>... <Point_n>
  13345.   [OBJECT_MODIFIER...]}
  13346. The float Number_Of_Points tells how many points are used to
  13347. define the polygon.  The points <Point_1> through <Point_n>
  13348. describe the polygon or polygons.  A polygon can contain any
  13349. number of sub-polygons, either overlapping or not. In places
  13350. where an even number of polygons overlaps a hole appears. When
  13351. you repeat the first point of a sub-polygon, it closes it and
  13352. starts a new sub-polygon's point sequence. This means that all
  13353. points of a sub-polygon are different.
  13354.  
  13355. If the last sub-polygon is not closed a warning is issued and the
  13356. program automatically closes the polygon. This is useful because
  13357. polygons imported from other programs may not be closed, i.e.
  13358. their first and last point are not the same.
  13359.  
  13360. All points of a polygon are three-dimensional vectors that have
  13361. to lay on the same plane. If this is not the case an error
  13362. occurs. It is common to use two-dimensional vectors to describe
  13363. the polygon. POV-Ray assumes that the z value is zero in this
  13364. case.
  13365.  
  13366. A square polygon that matches the default planar image map is
  13367. simply:
  13368.  
  13369.   polygon {
  13370.     4,
  13371.     <0, 0>, <0, 1>, <1, 1>, <1, 0>
  13372.     texture {
  13373.       finish { ambient 1 diffuse 0 }
  13374.       pigment { image_map { gif "test.gif"  } }
  13375.     }
  13376.     //scale and rotate as needed here
  13377.   }
  13378. The sub-polygon feature can be used to generate complex shapes
  13379. like the letter "P", where a hole is cut into another polygon:
  13380.  
  13381.   #declare P = polygon {
  13382.     12,
  13383.     <0, 0>, <0, 6>, <4, 6>, <4, 3>, <1, 3>, <1, 0>, <0, 0>,
  13384.     <1, 4>, <1, 5>, <3, 5>, <3, 4>, <1, 4>
  13385.   }
  13386. The first sub-polygon (on the first line) describes the outer
  13387. shape of the letter "P". The second sub-polygon (on the second
  13388. line) describes the rectangular hole that is cut in the top of
  13389. the letter "P". Both rectangles are closed, i.e. their first and
  13390. last points are the same.
  13391.  
  13392. The feature of cutting holes into a polygon is based on the
  13393. polygon inside/outside test used. A point is considered to be
  13394. inside a polygon if a straight line drawn from this point in an
  13395. arbitrary direction crosses an odd number of edges (this is known
  13396. as Jordan's curve theorem).
  13397.  
  13398. Another very complex example showing one large triangle with
  13399. three small holes and three separate, small triangles is given
  13400. below:
  13401.  
  13402.   polygon {
  13403.     28,
  13404.     <0, 0> <1, 0> <0, 1> <0, 0>          // large outer triangle
  13405.     <.3, .7> <.4, .7> <.3, .8> <.3, .7>  // small outer triangle
  13406. #1
  13407.     <.5, .5> <.6, .5> <.5, .6> <.5, .5>  // small outer triangle
  13408. #2
  13409.     <.7, .3> <.8, .3> <.7, .4> <.7, .3>  // small outer triangle
  13410. #3
  13411.     <.5, .2> <.6, .2> <.5, .3> <.5, .2>  // inner triangle #1
  13412.     <.2, .5> <.3, .5> <.2, .6> <.2, .5>  // inner triangle #2
  13413.     <.1, .1> <.2, .1> <.1, .2> <.1, .1>  // inner triangle #3
  13414.   }
  13415.  
  13416. 4.5.2.5   Triangle and Smooth Triangle
  13417. The triangle primitive is available in order to make more complex
  13418. objects than the built-in shapes will permit. Triangles are
  13419. usually not created by hand but are converted from other files or
  13420. generated by utilities. A triangle is defined by
  13421.  
  13422. TRIANGLE:
  13423.   triangle { <Corner_1>, <Corner_2>, <Corner_3>
  13424.   [OBJECT_MODIFIER...] }
  13425. where <Corner_n> is a vector defining the x, y, z coordinates of
  13426. each corner of the triangle.
  13427.  
  13428. Because triangles are perfectly flat surfaces it would require
  13429. extremely large numbers of very small triangles to approximate a
  13430. smooth, curved surface. However much of our perception of smooth
  13431. surfaces is dependent upon the way light and shading is done. By
  13432. artificially modifying the surface normals we can simulate a
  13433. smooth surface and hide the sharp-edged seams between individual
  13434. triangles.
  13435.  
  13436. The smooth_triangle primitive is used for just such purposes. The
  13437. smooth triangles use a formula called Phong normal interpolation
  13438. to calculate the surface normal for any point on the triangle
  13439. based on normal vectors which you define for the three corners.
  13440. This makes the triangle appear to be a smooth curved surface. A
  13441. smooth triangle is defined by
  13442.  
  13443. SMOOTH_TRIANGLE:
  13444.   smooth_triangle {
  13445.        <Corner_1>, <Normal_1>,
  13446.        <Corner_2>, <Normal_2>,
  13447.        <Corner_3>, <Normal_3>
  13448.        [OBJECT_MODIFIER...]
  13449.   }
  13450. where the corners are defined as in regular triangles and
  13451. <Normal_n> is a vector describing the direction of the surface
  13452. normal at each corner.
  13453.  
  13454. These normal vectors are prohibitively difficult to compute by
  13455. hand. Therefore smooth triangles are almost always generated by
  13456. utility programs. To achieve smooth results, any triangles which
  13457. share a common vertex should have the same normal vector at that
  13458. vertex. Generally the smoothed normal should be the average of
  13459. all the actual normals of the triangles which share that point.
  13460.  
  13461. The mesh object is a way to combine many triangle and
  13462. smooth_triangle objects together in a very efficient way.  See
  13463. "Mesh" for details.
  13464.  
  13465.  
  13466. 4.5.3     Infinite Solid Primitives
  13467. There are five polynomial primitive shapes that are possibly
  13468. infinite and do not respond to automatic bounding. They are
  13469. plane, cubic, poly, quadric and quartic. They do have a well
  13470. defined inside and may be used in CSG and inside a clipped_by
  13471. statement. As with all shapes they can be translated, rotated and
  13472. scaled.
  13473.  
  13474.  
  13475. 4.5.3.1   Plane
  13476. The plane primitive is a simple way to define an infinite flat
  13477. surface. The plane is specified as follows:
  13478.  
  13479. PLANE:
  13480.   plane { <Normal>, Distance [OBJECT_MODIFIERS...] }
  13481. The <Normal> vector defines the surface normal of the plane. A
  13482. surface normal is a vector which points up from the surface at a
  13483. 90 degree angle. This is followed by a float value that gives the
  13484. distance along the normal that the plane is from the origin (that
  13485. is only true if the normal vector has unit length; see below).
  13486. For example:
  13487.  
  13488.   plane { <0, 1, 0>, 4 }
  13489. This is a plane where straight up is defined in the positive y-
  13490. direction. The plane is 4 units in that direction away from the
  13491. origin. Because most planes are defined with surface normals in
  13492. the direction of an axis you will often see planes defined using
  13493. the x, y or z built-in vector identifiers. The example above
  13494. could be specified as:
  13495.  
  13496.   plane { y, 4 }
  13497. The plane extends infinitely in the x- and z-directions. It
  13498. effectively divides the world into two pieces. By definition the
  13499. normal vector points to the outside of the plane while any points
  13500. away from the vector are defined as inside. This inside/outside
  13501. distinction is important when using planes in CSG and clipped_by.
  13502. It is also important when using fog or atmospheric media.  If you
  13503. place a camera on the "inside" half of the world, then the fog or
  13504. media will not appear.  Such issues arise in any solid object but
  13505. it is more common with planes.  Users typically know when they've
  13506. accidentally placed a camera inside a sphere or box but "inside a
  13507. plane" is an unusual concept.  You can reverse the inside/outside
  13508. properties of an object by adding the object modifier inverse.
  13509. See "Inverse" and "Empty and Solid Objects" for details.
  13510.  
  13511. A plane is called a polynomial shape because it is defined by a
  13512. first order polynomial equation. Given a plane:
  13513.  
  13514.   plane { <A, B, C>, D }
  13515. it can be represented by the equation  A*x + B*y + C*z -
  13516. D*sqrt(A2 + B2 + C2) = 0.
  13517.  
  13518. Therefore our example plane{y,4} is actually the polynomial
  13519. equation y=4. You can think of this as a set of all x, y, z
  13520. points where all have y values equal to 4, regardless of the x or
  13521. z values.
  13522.  
  13523. This equation is a first order polynomial because each term
  13524. contains only single powers of x, y or z. A second order equation
  13525. has terms like x2, y2, z2, xy, xz and yz. Another name for a 2nd
  13526. order equation is a quadric equation. Third order polys are
  13527. called cubics. A 4th order equation is a quartic. Such shapes are
  13528. described in the sections below.
  13529.  
  13530.  
  13531. 4.5.3.2   Poly, Cubic and Quartic
  13532. Higher order polynomial surfaces may be defined by the use of a
  13533. poly shape. The syntax is
  13534.  
  13535. POLY:
  13536.   poly { Order, <A1, A2, A3,... An> [POLY_MODIFIERS...] }
  13537. POLY_MODIFIERS:
  13538.   sturm   |   OBJECT_MODIFIER
  13539. where Order is an integer number from 2 to 7 inclusively that
  13540. specifies the order of the equation. A1, A2, ... An are float
  13541. values for the coefficients of the equation. There are m such
  13542. terms where
  13543.  
  13544.   n = ((Order+1)*(Order+2)*(Order+3))/6.
  13545.  
  13546. The cubic object is an alternate way to specify 3rd order polys.
  13547. Its syntax is:
  13548.  
  13549. CUBIC:
  13550.   cubic { <A1, A2, A3,... A20> [POLY_MODIFIERS...] }
  13551. Also 4th order equations may be specified with the quartic
  13552. object.  Its syntax is:
  13553.  
  13554. QUARTIC:
  13555.   quartic { <A1, A2, A3,... A35> [POLY_MODIFIERS...] }
  13556. The following table shows which polynomial terms correspond to
  13557. which x,y,z factors.  Remember cubic is actually a 3rd order
  13558. polynomial and quartic is 4th order.
  13559.    2n  3r 4th 5th 6th  7th         5t  6th  7th         6t 7t
  13560.   d   d                         h                 h  h
  13561. A1 x2  x3 x4  x5  x6   x7       A4 y3  xy3  x2y3    A8  z3 xz
  13562.                              1                 1      3
  13563. A2 xy  x2 x3y x4y x5y  x6y      A4 y2  xy2  x2y2    A8  z2 xz
  13564.       y                      2  z3  z3   z3      2      2
  13565. A3 xz  x2 x3z x4z x5z  x5z      A4 y2  xy2  x2y2    A8  z  xz
  13566.       z                      3  z2  z2   z2      3
  13567. A4 x   x2 x3  x4  x5   x5       A4 y2  xy2  x2y2    A8  1  x
  13568.                              4  z   z    z       4
  13569. A5 y2  xy x2y x3y x4y2 x5y2     A4 y2  xy2  x2y2    A8     y7
  13570.       2  2   2               5                 5
  13571. A6 yz  xy x2y x3y x4yz x5yz     A4 yz  xyz  x2yz    A8     y6
  13572.       z  z   z               6  4   4    4       6      z
  13573. A7 y   xy x2y x3y x4y  x5y      A4 yz  xyz  x2yz    A8     y6
  13574.                              7  3   3    3       7
  13575. A8 z2  xz x2z x3z x4z2 x5z2     A4 yz  xyz  x2yz    A8     y5
  13576.       2  2   2               8  2   2    2       8      z2
  13577. A9 z   xz x2z x3z x4z  x5z      A4 yz  xyz  x2yz    A8     y5
  13578.                              9                 9      z
  13579. A1 1   x  x2  x3  x4   x5       A5 y   xy   x2y     A9     y5
  13580. 0                            0                 0
  13581. A1     y3 xy3 x2y x3y3 x4y3     A5 z5  xz5  x2z5    A9     y4
  13582. 1            3               1                 1      z3
  13583. A1     y2 xy2 x2y x3y2 x4y2     A5 z4  xz4  x2z4    A9     y4
  13584. 2     z  z   2z  z    z       2                 2      z2
  13585. A1     y2 xy2 x2y x3y2 x4y2     A5 z3  xz3  x2z3    A9     y4
  13586. 3            2               3                 3      z
  13587. A1     yz xyz x2y x3yz x4yz     A5 z2  xz2  x2z2    A9     y4
  13588. 4     2  2   z2  2    2       4                 4
  13589. A1     yz xyz x2y x3yz x4yz     A5 z   xz   x2z     A9     y3
  13590. 5            z               5                 5      z4
  13591. A1     y  xy  x2y x3y  x4y      A5 1   x    x2      A9     y3
  13592. 6                            6                 6      z3
  13593. A1     z3 xz3 x2z x3z3 x4z3     A5     y6   xy6     A9     y3
  13594. 7            3               7                 7      z2
  13595. A1     z2 xz2 x2z x3z2 x4z2     A5     y5z  xy5z    A9     y3
  13596. 8            2               8                 8      z
  13597. A1     z  xz  x2z x3z  x4z      A5     y5   xy5     A9     y3
  13598. 9                            9                 9
  13599. A2     1  x   x2  x3   x4       A6     y4z  xy4z    A1     y2
  13600. 0                            0      2    2       00     z5
  13601. A2        y4  xy4 x2y4 x3y4     A6     y4z  xy4z    A1     y2
  13602. 1                            1                 01     z4
  13603. A2        y3z xy3 x2y3 x3y3     A6     y4   xy4     A1     y2
  13604. 2            z   z    z       2                 02     z3
  13605. A2        y3  xy3 x2y3 x3y3     A6     y3z  xy3z    A1     y2
  13606. 3                            3      3    3       03     z2
  13607. A2        y2z xy2 x2y2 x3y2     A6     y3z  xy3z    A1     y2
  13608. 4        2   z2  z2   z2      4      2    2       04     z
  13609. A2        y2z xy2 x2y2 x3y2     A6     y3z  xy3z    A1     y2
  13610. 5            z   z    z       5                 05
  13611. A2        y2  xy2 x2y2 x3y2     A6     y3   xy3     A1     yz
  13612. 6                            6                 06     6
  13613. A2        yz3 xyz x2yz x3yz     A6     y2z  xy2z    A1     yz
  13614. 7            3   3    3       7      4    4       07     5
  13615. A2        yz2 xyz x2yz x3yz     A6     y2z  xy2z    A1     yz
  13616. 8            2   2    2       8      3    3       08     4
  13617. A2        yz  xyz x2yz x3yz     A6     y2z  xy2z    A1     yz
  13618. 9                            9      2    2       09     3
  13619. A3        y   xy  x2y  x3y      A7     y2z  xy2z    A1     yz
  13620. 0                            0                 10     2
  13621. A3        z4  xz4 x2z4 x3z4     A7     y2   xy2     A1     yz
  13622. 1                            1                 11
  13623. A3        z3  xz3 x2z3 x3z3     A7     yz5  xyz5    A1     y
  13624. 2                            2                 12
  13625. A3        z2  xz2 x2z2 x3z2     A7     yz4  xyz4    A1     z7
  13626. 3                            3                 13
  13627. A3        z   xz  x2z  x3z      A7     yz3  xyz3    A1     z6
  13628. 4                            4                 14
  13629. A3        1   x   x2   x3       A7     yz2  xyz2    A1     z5
  13630. 5                            5                 15
  13631. A3            y5  xy5  x2y5     A7     yz   xyz     A1     z4
  13632. 6                            6                 16
  13633. A3            y4z xy4z x2y4     A7     y    xy      A1     z3
  13634. 7                     z       7                 17
  13635. A3            y4  xy4  x2y4     A7     z6   xz6     A1     z2
  13636. 8                            8                 18
  13637. A3            y3z xy3z x2y3     A7     z5   xz5     A1     z
  13638. 9            2   2    z2      9                 19
  13639. A4            y3z xy3z x2y3     A8     z4   xz4     A1     1
  13640. 0                     z       0                 20
  13641. Polynomial shapes can be used to describe a large class of shapes
  13642. including the torus, the lemniscate, etc. For example, to declare
  13643. a quartic surface requires that each of the coefficients (A1 ...
  13644. A35) be placed in order into a single long vector of 35 terms.
  13645.  
  13646. As an example let's define a torus the hard way. A Torus can be
  13647. represented by the equation:
  13648.  
  13649.  x4 + y4 + z4 + 2 x2 y2 + 2 x2 z2 + 2 y2 z2 -
  13650.  2 (r_02 + r_12) x2 + 2 (r_02 - r_12) y2 -
  13651.  2 (r_02 + r_12) z2 + (r_02 - r_12)2 = 0
  13652. Where r_0 is the major radius of the torus, the distance from the
  13653. hole of the donut to the middle of the ring of the donut, and r_1
  13654. is the minor radius of the torus, the distance from the middle of
  13655. the ring of the donut to the outer surface. The following object
  13656. declaration is for a torus having major radius 6.3 minor radius
  13657. 3.5 (Making the maximum width just under 20).
  13658.  
  13659.   // Torus having major radius sqrt(40), minor radius sqrt(12)
  13660.   quartic {
  13661.     < 1,   0,   0,   0,   2,   0,   0,   2,   0,
  13662.    -104,   0,   0,   0,   0,   0,   0,   0,   0,
  13663.       0,   0,   1,   0,   0,   2,   0,  56,   0,
  13664.       0,   0,   0,   1,   0, -104,  0, 784 >
  13665.     sturm
  13666.   }
  13667. Poly, cubic and quartics are just like quadrics in that you don't
  13668. have to understand what one is to use one. The file shapesq.inc
  13669. has plenty of pre-defined quartics for you to play with.
  13670.  
  13671. Polys use highly complex computations and will not always render
  13672. perfectly. If the surface is not smooth, has dropouts, or extra
  13673. random pixels, try using the optional keyword sturm in the
  13674. definition. This will cause a slower but more accurate
  13675. calculation method to be used. Usually, but not always, this will
  13676. solve the problem. If sturm doesn't work, try rotating or
  13677. translating the shape by some small amount.
  13678.  
  13679. There are really so many different polynomial shapes, we can't
  13680. even begin to list or describe them all. If you are interested
  13681. and mathematically inclined, an excellent reference book for
  13682. curves and surfaces where you'll find more polynomial shape
  13683. formulas is:
  13684.  
  13685.   "The CRC Handbook of Mathematical Curves and Surfaces"
  13686.   David von Seggern
  13687.   CRC Press, 1990
  13688.  
  13689. 4.5.3.3   Quadric
  13690. The quadric object can produce shapes like paraboloids (dish
  13691. shapes) and hyperboloids (saddle or hourglass shapes). It can
  13692. also produce ellipsoids, spheres, cones, and cylinders but you
  13693. should use the sphere, cone, and cylinder objects built into POV-
  13694. Ray because they are faster than the quadric version.  Note that
  13695. you do not confuse "quaDRic" with "quaRTic". A quadric is a 2nd
  13696. order polynomial while a quartic is 4th order. Quadrics render
  13697. much faster and are less error-prone but produce less complex
  13698. objects.  The syntax is:
  13699.  
  13700. QUADRIC:
  13701.   quadric { <A,B,C>,<D,E,F>,<G,H,I>,J  [OBJECT_MODIFIERS...] }
  13702. Although the syntax actually will parse 3 vector expressions
  13703. followed by a float, we traditionally have written the syntax as
  13704. above where A through J are float expressions.  These 10 float
  13705. that define a surface of x, y, z points which satisfy the
  13706. equation
  13707.  
  13708.  A x2 + B y2 + C z2 + D xy + E xz + F yz + G x + H y + I z + J =
  13709. 0
  13710. Different values of A, B, C, ... J will give different shapes. If
  13711. you take any three dimensional point and use its x, y and z
  13712. coordinates in the above equation the answer will be 0 if the
  13713. point is on the surface of the object. The answer will be
  13714. negative if the point is inside the object and positive if the
  13715. point is outside the object.  Here are some examples:
  13716. X2 + Y2 + Z2 -  Sphere
  13717. 1 = 0
  13718. X2 + Y2 - 1 = 0 Infinite cylinder
  13719.                 along the Z axis
  13720. X2 + Y2 - Z2 =  Infinite cone
  13721. 0               along the Z axis
  13722. The easiest way to use these shapes is to include the standard
  13723. file shapes.inc into your program. It contains several pre-
  13724. defined quadrics and you can transform these pre-defined shapes
  13725. (using translate, rotate and scale) into the ones you want. For a
  13726. complete list, see the file shapes.inc.
  13727.  
  13728.  
  13729. 4.5.4     Constructive Solid Geometry
  13730. In addition to all of the primitive shapes POV-Ray supports, you
  13731. can also combine multiple simple shapes into complex shapes using
  13732. Constructive Solid Geometry (CSG).  There are four basic types of
  13733. CSG operations: union, intersection, difference, and merge.  CSG
  13734. objects can be composed of primitives or other CSG objects to
  13735. create more, and more complex shapes.
  13736.  
  13737.  
  13738. 4.5.4.1   Inside and Outside
  13739. Most shape primitives, like spheres, boxes and blobs divide the
  13740. world into two regions. One region is inside the object and one
  13741. is outside. Given any point in space you can say it's either
  13742. inside or outside any particular primitive object. Well, it could
  13743. be exactly on the surface but this case is rather hard to
  13744. determine due to numerical problems.
  13745.  
  13746. Even planes have an inside and an outside. By definition, the
  13747. surface normal of the plane points towards the outside of the
  13748. plane. You should note that triangles and triangle-based shapes
  13749. cannot be used as solid objects in CSG since they have no well
  13750. defined inside and outside.
  13751.  
  13752. CSG uses the concepts of inside and outside to combine shapes
  13753. together as explained in the following sections.
  13754.  
  13755. Imagine you have two objects that partially overlap like shown in
  13756. the figure below. Four different areas of points can be
  13757. distinguished: points that are neither in object A nor in object
  13758. B, points that are in object A but not in object B, points that
  13759. are not in object A but in object B and last not least points
  13760. that are in object A and object B.
  13761.  
  13762.                                 
  13763.                     Two overlapping objects.
  13764. Keeping this in mind it will be quite easy to understand how the
  13765. CSG operations work.
  13766.  
  13767. When using CSG it is often useful to invert an object so that
  13768. it'll be inside-out. The appearance of the object is not changed,
  13769. just the way that POV-Ray perceives it. When the inverse keyword
  13770. is used the inside of the shape is flipped to become the outside
  13771. and vice versa.
  13772.  
  13773. The inside/outside distinction is not important for a union, but
  13774. is important for intersection, difference, and merge.Therefore
  13775. any objects may be combined using union but only solid objects,
  13776. i.e. objects that have a well-defined interior can be used in the
  13777. other kinds of CSG. The objects described in "Finite Patch
  13778. Primitives" have no well defined inside/outside.  All objects
  13779. described in the sections "Finite Solid Primitives" and "Infinite
  13780. Solid Primitives".
  13781.  
  13782.  
  13783. 4.5.4.2   Union
  13784.                                 
  13785.                     The union of two objects.
  13786. The simplest kind of CSG is the union. The syntax is:
  13787.  
  13788. UNION:
  13789.   union { OBJECTS...  [OBJECT_MODIFIERS...] }
  13790. Unions are simply glue used to bind two or more shapes into a
  13791. single entity that can be manipulated as a single object. The
  13792. image above shows the union of A and B. The new object created by
  13793. the union operation can be scaled, translated and rotated as a
  13794. single shape. The entire union can share a single texture but
  13795. each object contained in the union may also have its own texture,
  13796. which will override any texture statements in the parent object.
  13797.  
  13798. You should be aware that the surfaces inside the union will not
  13799. be removed. As you can see from the figure this may be a problem
  13800. for transparent unions. If you want those surfaces to be removed
  13801. you'll have to use the merge operations explained in a later
  13802. section.
  13803.  
  13804. The following union will contain a box and a sphere.
  13805.  
  13806.   union {
  13807.     box { <-1.5, -1, -1>, <0.5, 1, 1> }
  13808.     cylinder { <0.5, 0, -1>, <0.5, 0, 1>, 1 }
  13809.   }
  13810. Earlier versions of POV-Ray placed restrictions on unions so you
  13811. often had to combine objects with composite statements.  Those
  13812. earlier restrictions have been lifted so composite is no longer
  13813. needed. It is still supported for backwards compatibility.
  13814.  
  13815.  
  13816. 4.5.4.3   Intersection
  13817. The intersection object creates a shape containing only those
  13818. areas where all components overlap.  A point is part an
  13819. intersection if it is inside both objects, A and B, as show in
  13820. the figure below.
  13821.  
  13822.                                 
  13823.                 The intersection of two objects.
  13824. The syntax is:
  13825.  
  13826. INTERSECTION:
  13827.   intersection { SOLID_OBJECTS...  [OBJECT_MODIFIERS...] }
  13828. The component objects must have well defined inside/outside
  13829. properties.  Patch objects are not allowed.  Note that if all
  13830. components do not overlap, the intersection object disappears.
  13831.  
  13832. Here is an example that overlaps:
  13833.  
  13834.   intersection {
  13835.     box { <-1.5, -1, -1>, <0.5, 1, 1> }
  13836.     cylinder { <0.5, 0, -1>, <0.5, 0, 1>, 1 }
  13837.   }
  13838.  
  13839. 4.5.4.4   Difference
  13840. The CSG difference operation takes the intersection between the
  13841. first object and the inverse of all subsequent objects. Thus only
  13842. points inside object A and outside object B belong to the
  13843. difference of both objects.
  13844.  
  13845. The results is a subtraction of the 2nd shape from the first
  13846. shape as shown in the figure below.
  13847.  
  13848.                                 
  13849.                The difference between two objects.
  13850. The syntax is:
  13851.  
  13852. DIFFERENCE:
  13853.   difference { SOLID_OBJECTS...  [OBJECT_MODIFIERS...] }
  13854. The component objects must have well defined inside/outside
  13855. properties.  Patch objects are not allowed.  Note that if the
  13856. first object is entirely inside the subtracted objects, the
  13857. difference object disappears.
  13858.  
  13859. Here is an example of a properly formed difference:
  13860.  
  13861.   difference {
  13862.     box { <-1.5, -1, -1>, <0.5, 1, 1> }
  13863.     cylinder { <0.5, 0, -1>, <0.5, 0, 1>, 1 }
  13864.   }
  13865. Note that internally, POV-Ray simply adds the inverse keyword to
  13866. the second (and subsequent) objects and then performs an
  13867. intersection.  The example above is equivalent to:
  13868.  
  13869.   intersection {
  13870.     box { <-1.5, -1, -1>, <0.5, 1, 1> }
  13871.     cylinder { <0.5, 0, -1>, <0.5, 0, 1>, 1 inverse }
  13872.   }
  13873.  
  13874. 4.5.4.5   Merge
  13875. The union operation just glues objects together, it does not
  13876. remove the objects' surfaces inside the union.  Under most
  13877. circumstances this doesn't matter.  However if a transparent
  13878. union is used, those interior surfaces will be visible.  The
  13879. merge operations can be used to avoid this problem. It works just
  13880. like union but it eliminates the inner surfaces like shown in the
  13881. figure below.
  13882.  
  13883.                                 
  13884.                   Merge removes inner surfaces.
  13885. The syntax is:
  13886.  
  13887. MERGE:
  13888.   merge { SOLID_OBJECTS...  [OBJECT_MODIFIERS...] }
  13889. The component objects must have well defined inside/outside
  13890. properties.  Patch objects are not allowed.  Note that merge is
  13891. slower rendering than union so it should only be used when it is
  13892. really necessary.
  13893.  
  13894.  
  13895. 4.5.5     Light Sources
  13896. The light_source is not really an object. Light sources have no
  13897. visible shape of their own.  They are just points or areas which
  13898. emit light. They are categorized as objects so that they can be
  13899. combined with regular objects using union.  Their full syntax is:
  13900.  
  13901. LIGHT_SOURCE:
  13902.   light_source { <Location>, COLOR [LIGHT_MODIFIERS...] }
  13903. LIGHT_MODIFIER:
  13904.   LIGHT_TYPE   |   SPOTLIGHT_ITEM   |
  13905.   AREA_LIGHT_ITEMS   |   GENERAL_LIGHT_MODIFIERS
  13906. LIGHT_TYPE:
  13907.   spotlight   |   shadowless   |   cylinder
  13908. SPOTLIGHT_ITEM:
  13909.   radius Radius   |   falloff Falloff   |   tightness Tightness
  13910.   |   point_at <Spot>
  13911. AREA_LIGHT_ITEM:
  13912.   area_light <Axis_1>, <Axis_2>, Size_1, Size_2   |
  13913.   adaptive Adaptive   |   jitter Jitter
  13914. GENERAL_LIGHT_MODIFIERS:
  13915.   looks_like { OBJECT }   |   TRANSFORMATION
  13916.   fade_distance Fade_Distance   |   fade_power Fade_Power   |
  13917.   media_attenuation [Bool]   |   media_interaction [Bool]
  13918. The different types of light sources and the optional modifiers
  13919. are described in the following sections.
  13920.  
  13921. The first two items are common to all light sources.  The
  13922. <Location> vector gives the location of the light.  The COLOR
  13923. gives the color of the light.  Only the red, green, and blue
  13924. components are significant.  Any transmit or filter values are
  13925. ignored.  Note that you vary the intensity of the light as well
  13926. as the color using this parameter.  A color such as rgb
  13927. <0.5,0.5,0.5> gives a white light that is half the normal
  13928. intensity.
  13929.  
  13930. All of the keywords or items in the syntax specification above
  13931. may appear in any order.  Some keywords only have effect if
  13932. specified with other keywords.  The keywords are grouped into
  13933. functional categories to make it clear which keywords work
  13934. together.  The GENERAL_LIGHT_MODIFIERS work with all types of
  13935. lights and all options.  Note that TRANSFORMATIONS such as
  13936. translate, rotate etc. may be applied but no other
  13937. OBJECT_MODIFIERS may be used.
  13938.  
  13939. There are four mutually exclusive light types.  If no LIGHT_TYPE
  13940. is specified it is a point light.  The other choices are
  13941. spotlight, shadowless, and cylinder.
  13942.  
  13943.  
  13944. 4.5.5.1   Point Lights
  13945. The simplest kid of light is a point light. A point light source
  13946. sends light of the specified color uniformly in all directions.
  13947. The default light type is a point source.  The <Location> and
  13948. COLOR is all that is required.  For example:
  13949.  
  13950.   light_source {
  13951.     <1000,1000,-1000>, rgb <1,0.75,0> //an orange light
  13952.   }
  13953.  
  13954. 4.5.5.2   Spotlights
  13955. Normally light radiates outward equally in all directions from
  13956. the source.  However the spotlight keyword can be used to create
  13957. a cone of light that is bright in the center and falls of to
  13958. darkness in a soft fringe effect at the edge.  Although the cone
  13959. of light fades to soft edges, objects illuminated by spotlights
  13960. still cast hard shadows.  The syntax is:
  13961.  
  13962. SPOTLIGHT_SOURCE:
  13963.   light_source { <Location>, COLOR spotlight
  13964.   [LIGHT_MODIFIERS...] }
  13965. LIGHT_MODIFIER:
  13966.   SPOTLIGHT_ITEM   |   AREA_LIGHT_ITEMS   |
  13967.   GENERAL_LIGHT_MODIFIERS
  13968. SPOTLIGHT_ITEM:
  13969.   radius Radius   |   falloff Falloff   |   tightness Tightness
  13970.   |   point_at <Spot>
  13971. The point_at keyword tells the spotlight to point at a particular
  13972. 3D coordinate.  A line from the location of the spotlight to the
  13973. point_at coordinate forms the center line of the cone of light.
  13974. The following illustration will be helpful in understanding how
  13975. these values relate to each other.
  13976.  
  13977.                                 
  13978.                   The geometry of a spotlight.
  13979. The falloff, radius, and tightness keywords control the way that
  13980. light tapers off at the edges of the cone.  These four keywords
  13981. apply only when the spotlight or cylinder keywords are used.
  13982.  
  13983. The falloff keyword specifies the overall size of the cone of
  13984. light.  This is the point where the light falls off to zero
  13985. intensity.  The float value you specify is the angle, in degrees,
  13986. between the edge of the cone and center line.  The radius keyword
  13987. specifies the size of the "hot-spot" at the center of the cone of
  13988. light.  The "hot-spot" is a brighter cone of light inside the
  13989. spotlight cone and has the same center line.  The radius value
  13990. specifies the angle, in degrees, between the edge of this bright,
  13991. inner cone and the center line.  The light inside the inner cone
  13992. is of uniform intensity.  The light between the inner and outer
  13993. cones tapers off to zero.
  13994.  
  13995. For example with radius 10 and falloff 20 the light from the
  13996. center line out to 10 degrees is full intensity.  From 10 to 20
  13997. degrees from the center line the light falls off to zero
  13998. intensity.  At 20 degrees or greater there is no light.  Note
  13999. that if the radius and falloff values are close or equal the
  14000. light intensity drops rapidly and the spotlight has a sharp edge.
  14001. The default values for both radius and falloff is 70.
  14002.  
  14003. The values for these two parameters are half the opening angles
  14004. of the corresponding cones, both angles have to be smaller than
  14005. 90 degrees. The light smoothly falls off between the radius and
  14006. the falloff angle like shown in the figures below (as long as the
  14007. radius angle is not negative).
  14008.  
  14009.                                 
  14010.    Intensity multiplier curve with a fixed falloff angle of 45
  14011.                             degrees.
  14012.                                 
  14013.    Intensity multiplier curve with a fixed radius angle of 45
  14014.                             degrees.
  14015. The tightness keyword is used to specify an additional
  14016. exponential softening of the edges.  The intensity of light at an
  14017. angle from the center line is given by: intensity *
  14018. cos(angle)tightness.  The default value for tightness is 10.
  14019. Lower tightness values will make the spotlight brighter, making
  14020. the spot wider and the edges sharper. Higher values will dim the
  14021. spotlight, making the spot tighter and the edges softer. Values
  14022. from 1 to 100 are acceptable.
  14023.  
  14024.                                 
  14025.  Intensity multiplier curve with fixed angle and falloff angles
  14026. of 30 and 60 degrees respectively and different tightness values.
  14027. You should note from the figures that the radius and falloff
  14028. angles interact with the tightness parameter. Only negative
  14029. radius angles will give the tightness value full control over the
  14030. spotlight's appearance as you can see from the figure below. In
  14031. that case the falloff angle has no effect and the lit area is
  14032. only determined by the tightness parameter.
  14033.  
  14034.                                 
  14035.    Intensity multiplier curve with a negative radius angle and
  14036.                    different tightness values.
  14037. Spotlights may be used anyplace that a normal light source is
  14038. used. Like any light sources, they are invisible. They may also
  14039. be used in conjunction with area lights.
  14040.  
  14041.  
  14042. 4.5.5.3   Cylindrical Lights
  14043. The cylinder keyword specifies a cylindrical light source that is
  14044. great for simulating laser beams.  Cylindrical light sources work
  14045. pretty much like spotlights except that the light rays are
  14046. constrained by a cylinder and not a cone. The syntax is:
  14047.  
  14048. CYLINDER_LIGHT_SOURCE:
  14049.   light_source { <Location>, COLOR cylinder [LIGHT_MODIFIERS...]
  14050.   }
  14051. LIGHT_MODIFIER:
  14052.   SPOTLIGHT_ITEM   |   AREA_LIGHT_ITEMS   |
  14053.   GENERAL_LIGHT_MODIFIERS
  14054. SPOTLIGHT_ITEM:
  14055.   radius Radius   |   falloff Falloff   |   tightness Tightness
  14056.   |   point_at <Spot>
  14057. The point_at, radius, falloff and tightness keywords control the
  14058. same features as with the spotlight.  See "Spotlights" for
  14059. details.
  14060.  
  14061. You should keep in mind that the cylindrical light source is
  14062. still a point light source. The rays are emitted from one point
  14063. and are only constraint by a cylinder. The light rays are not
  14064. parallel.
  14065.  
  14066.  
  14067. 4.5.5.4   Area Lights
  14068. Area light sources occupy a finite, one- or two-dimensional area
  14069. of space. They can cast soft shadows because an object can
  14070. partially block their light.  Point sources are either totally
  14071. blocked or not blocked.
  14072.  
  14073. The area_light keyword in POV-Ray creates sources that are
  14074. rectangular in shape, sort of like a flat panel light. Rather
  14075. than performing the complex calculations that would be required
  14076. to model a true area light, it is approximated as an array of
  14077. point light sources spread out over the area occupied by the
  14078. light. The array-effect applies to shadows only.  The object's
  14079. illumination is still that of a point source.  The intensity of
  14080. each individual point light in the array is dimmed so that the
  14081. total amount of light emitted by the light is equal to the light
  14082. color specified in the declaration. The syntax is:
  14083. AREA_LIGHT_SOURCE:
  14084.   light_source { <Location>, COLOR area_light <Axis_1>,
  14085.   <Axis_2>, Size_1, Size_2
  14086.      [adaptive Adaptive] [ jitter Jitter ]
  14087.      [LIGHT_MODIFIERS...]
  14088.   }
  14089. The light's location and color are specified in the same way as a
  14090. for a regular light source.  Any type of light source may be an
  14091. area light.
  14092.  
  14093. The area_light command defines the size and orientation of the
  14094. area light as well as the number of lights in the light source
  14095. array. The vectors <Axis_1> and <Axis_2> specify the lengths and
  14096. directions of the edges of the light. Since the area lights are
  14097. rectangular in shape these vectors should be perpendicular to
  14098. each other. The larger the size of the light the thicker the soft
  14099. part of shadows will be. The integers Size_1 and Size_2 specify
  14100. the number of rows and columns of point sources of the. The more
  14101. lights you use the smoother your shadows will be but the longer
  14102. they will take to render.
  14103.  
  14104. Note that it is possible to specify spotlight parameters along
  14105. with the area light parameters to create area spotlights. Using
  14106. area spotlights is a good way to speed up scenes that use area
  14107. lights since you can confine the lengthy soft shadow calculations
  14108. to only the parts of your scene that need them.
  14109.  
  14110. An interesting effect can be created using a linear light source.
  14111. Rather than having a rectangular shape, a linear light stretches
  14112. along a line sort of like a thin fluorescent tube. To create a
  14113. linear light just create an area light with one of the array
  14114. dimensions set to 1.
  14115.  
  14116. The jitter command is optional. When used it causes the positions
  14117. of the point lights in the array to be randomly jittered to
  14118. eliminate any shadow banding that may occur. The jittering is
  14119. completely random from render to render and should not be used
  14120. when generating animations.
  14121.  
  14122. The adaptive command is used to enable adaptive sampling of the
  14123. light source. By default POV-Ray calculates the amount of light
  14124. that reaches a surface from an area light by shooting a test ray
  14125. at every point light within the array. As you can imagine this is
  14126. very slow. Adaptive sampling on the other hand attempts to
  14127. approximate the same calculation by using a minimum number of
  14128. test rays. The number specified after the keyword controls how
  14129. much adaptive sampling is used. The higher the number the more
  14130. accurate your shadows will be but the longer they will take to
  14131. render. If you're not sure what value to use a good starting
  14132. point is adaptive 1. The adaptive keyword only accepts integer
  14133. values and cannot be set lower than 0.
  14134.  
  14135. When performing adaptive sampling POV-Ray starts by shooting a
  14136. test ray at each of the four corners of the area light. If the
  14137. amount of light received from all four corners is approximately
  14138. the same then the area light is assumed to be either fully in
  14139. view or fully blocked. The light intensity is then calculated as
  14140. the average intensity of the light received from the four
  14141. corners. However, if the light intensity from the four corners
  14142. differs significantly then the area light is partially blocked.
  14143. The area light is split into four quarters and each section is
  14144. sampled as described above. This allows POV-Ray to rapidly
  14145. approximate how much of the area light is in view without having
  14146. to shoot a test ray at every light in the array. Visually the
  14147. sampling goes like shown below.
  14148.  
  14149.                                 
  14150.                   Area light adaptive samples.
  14151. While the adaptive sampling method is fast (relatively speaking)
  14152. it can sometimes produces inaccurate shadows. The solution is to
  14153. reduce the amount of adaptive sampling without completely turning
  14154. it off. The number after the adaptive keyword adjusts the number
  14155. of times that the area light will be split before the adaptive
  14156. phase begins.  For example if you use adaptive 0 a minimum of 4
  14157. rays will be shot at the light. If you use adaptive 1 a minimum
  14158. of 9 rays will be shot (adaptive 2 gives 25 rays, adaptive 3
  14159. gives 81 rays, etc). Obviously the more shadow rays you shoot the
  14160. slower the rendering will be so you should use the lowest value
  14161. that gives acceptable results.
  14162.  
  14163. The number of rays never exceeds the values you specify for rows
  14164. and columns of points. For example area_light x,y,4,4 specifies a
  14165. 4 by 4 array of lights. If you specify adaptive 3 it would mean
  14166. that you should start with a 9 by 9 array. In this case no
  14167. adaptive sampling is done. The 4 by 4 array is used.
  14168.  
  14169.  
  14170. 4.5.5.5   Shadowless Lights
  14171. Using the shadowless keyword you can stop a light source from
  14172. casting shadows.  These lights are sometimes called "fill
  14173. lights".  They are another way to simulate ambient light however
  14174. shadowless lights have a definite source.  The syntax is:
  14175.  
  14176. SHADOWLESS_LIGHT_SOURCE:
  14177.   light_source { <Location>, COLOR  shadowless
  14178.   [LIGHT_MODIFIERS...] }
  14179. LIGHT_MODIFIER:
  14180.   AREA_LIGHT_ITEMS   |   GENERAL_LIGHT_MODIFIERS
  14181. Shadowless may be used with area_light but not spotlight or
  14182. cylinder.
  14183.  
  14184.  
  14185. 4.5.5.6   Looks_like
  14186. Normally the light source itself has no visible shape. The light
  14187. simply radiates from an invisible point or area. You may give a
  14188. light source any shape by adding a looks_like { OBJECT }
  14189. statement.
  14190.  
  14191. There is an implied no_shadow attached to the looks_like object
  14192. so that light is not blocked by the object. Without the automatic
  14193. no_shadow the light inside the object would not escape. The
  14194. object would, in effect, cast a shadow over everything.
  14195.  
  14196. If you want the attached object to block light then you should
  14197. attach it with a union and not a looks_like as follows:
  14198.  
  14199.   union {
  14200.     light_source { <100, 200, -300> color White }
  14201.     object { My_Lamp_Shape }
  14202.   }
  14203. Presumably parts of the lamp shade are transparent to let some
  14204. light out.
  14205.  
  14206.  
  14207. 4.5.5.7   Light Fading
  14208. By default POV-Ray does not diminish light from any light source
  14209. as it travels through space. In order to get a more realistic
  14210. effect fade_distance and fade_power keywords followed by float
  14211. values can be used to model the distance based falloff in light
  14212. intensity.
  14213.  
  14214. The fade_distance Fade_Distance is used to specify the distance
  14215. at which the full light intensity arrives, i. e. the intensity
  14216. which was given by the COLOR specification. The actual
  14217. attenuation is described by the fade_power Fade_Power, which
  14218. determines the falloff rate. For example linear or quadratic
  14219. falloff can be used by setting fade_power to 1 or 2 respectively.
  14220. The complete formula to calculate the factor by which the light
  14221. is attenuated is
  14222.  
  14223.                                 
  14224. with d being the distance the light has traveled.
  14225.  
  14226.                                 
  14227.        Light fading functions for different fading powers.
  14228. You should note two important facts: First, for Fade_Distance
  14229. larger than one the light intensity at distances smaller than
  14230. Fade_Distance actually increases. This is necessary to get the
  14231. light source color if the distance traveled equals the
  14232. Fade_Distance. Second, only light coming directly from light
  14233. sources is attenuated. Reflected or refracted light is not
  14234. attenuated by distance.
  14235.  
  14236.  
  14237. 4.5.5.8   Atmospheric Media Interaction
  14238. By default light sources will interact with an atmosphere added
  14239. to the scene. This behaviour can be switched off by using
  14240. media_interaction off keyword inside the light source statement.
  14241. Note in POV-Ray 3.0 this feature was turned off and on with the
  14242. atmosphere keyword.
  14243.  
  14244. 4.5.5.9   Atmospheric Attenuation
  14245. Normally light coming from light sources is not influenced by fog
  14246. or atmospheric media. This can be changed by turning the
  14247. media_attenuation on for a given light source on. All light
  14248. coming from this light source will now be diminished as it
  14249. travels through the fog or media.  This results in an distance-
  14250. based, exponential intensity falloff ruled by the used fog or
  14251. media. If there is no fog or media no change will be seen. Note
  14252. in POV-Ray 3.0 this feature was turned off and on with the
  14253. atmospheric_attenuation keyword.
  14254.  
  14255. 4.5.6     Object Modifiers
  14256. A variety of modifiers may be attached to objects. The following
  14257. items may be applied to any object:
  14258.  
  14259. OBJECT_MODIFIER:
  14260.   clipped_by { UNTEXTURED_SOLID_OBJECT... }   |   clipped_by {
  14261.   bounded_by }   |
  14262.   bounded_by { UNTEXTURED_SOLID_OBJECT... }   |   bounded_by {
  14263.   clipped_by }   |
  14264.   no_shadow   |   inverse   |   sturm [ Bool ]   |   hierarchy [
  14265.   Bool ]   |
  14266.   interior { INTERIOR_ITEMS... }   |
  14267.   material { [MATERIAL_IDENTIFIER][MATERIAL_ITEMS...] }   |
  14268.   texture { TEXTURE_BODY }   |   pigment { PIGMENT_BODY }   |
  14269.   normal { NORMAL_BODY }   |   finish { FINISH_ITEMS... }   |
  14270.   TRANSFORMATION
  14271. Transformations such as translate, rotate and scale have already
  14272. been discussed. The modifiers "Textures" and its parts "Pigment",
  14273. "Normal", and "Finish" as well as "Interior", and "Media" (which
  14274. is part of interior) are each in major chapters of their own
  14275. below. In the sub-sections below we cover several other important
  14276. modifiers: clipped_by, bounded_by, material, no_shadow, hollow,
  14277. inverse, sturm, and hierarchy. Although the examples below use
  14278. object statements and object identifiers, these modifiers may be
  14279. used on any type of object such as sphere, box etc.
  14280.  
  14281.  
  14282. 4.5.6.1   Clipped_By
  14283. The clipped_by statement is technically an object modifier but it
  14284. provides a type of CSG similar to CSG intersection. The syntax
  14285. is:
  14286.  
  14287. CLIPPED_BY:
  14288.   clipped_by { UNTEXTURED_SOLID_OBJECT... }   |   clipped_by {
  14289.   bounded_by }
  14290. Where UNTEXTURED_SOLID_OBJECT is one or more solid objects which
  14291. have had no texture applied.  For example:
  14292.  
  14293.   object {
  14294.     My_Thing
  14295.     clipped_by{plane{y,0}}
  14296.   }
  14297. Every part of the object My_Thing that is inside the plane is
  14298. retained while the remaining part is clipped off and discarded.
  14299. In an intersection object the hole is closed off. With clipped_by
  14300. it leaves an opening. For example the following figure shows
  14301. object A being clipped by object B.
  14302.  
  14303.                                 
  14304.               An object clipped by another object.
  14305. You may use clipped_by to slice off portions of any shape. In
  14306. many cases it will also result in faster rendering times than
  14307. other methods of altering a shape.  Occasionally you will want to
  14308. use the clipped_by and bounded_by options with the same object.
  14309. The following shortcut saves typing and uses less memory.
  14310.  
  14311.   object {
  14312.     My_Thing
  14313.     bounded_by { box { <0,0,0>, <1,1,1> } }
  14314.     clipped_by { bounded_by }
  14315.   }
  14316. This tells POV-Ray to use the same box as a clip that was used as
  14317. a bounds.
  14318.  
  14319.  
  14320. 4.5.6.2   Bounded_By
  14321. The calculations necessary to test if a ray hits an object can be
  14322. quite time consuming. Each ray has to be tested against every
  14323. object in the scene. POV-Ray attempts to speed up the process by
  14324. building a set of invisible boxes, called bounding boxes, which
  14325. cluster the objects together. This way a ray that travels in one
  14326. part of the scene doesn't have to be tested against objects in
  14327. another, far away part of the scene. When large a number of
  14328. objects are present the boxes are nested inside each other. POV-
  14329. Ray can use bounding boxes on any finite object and even some
  14330. clipped or bounded quadrics. However infinite objects (such as a
  14331. planes, quartic, cubic and poly) cannot be automatically bound.
  14332. CSG objects are automatically bound if they contain finite (and
  14333. in some cases even infinite) objects. This works by applying the
  14334. CSG set operations to the bounding boxes of all objects used
  14335. inside the CSG object. For difference and intersection operations
  14336. this will hardly ever lead to an optimal bounding box. It's
  14337. sometimes better (depending on the complexity of the CSG object)
  14338. to have you place a bounding shape yourself using a bounded_by
  14339. statement.
  14340.  
  14341. Normally bounding shapes are not necessary but there are cases
  14342. where they can be used to speed up the rendering of complex
  14343. objects. Bounding shapes tell the ray-tracer that the object is
  14344. totally enclosed by a simple shape. When tracing rays, the ray is
  14345. first tested against the simple bounding shape. If it strikes the
  14346. bounding shape the ray is further tested against the more
  14347. complicated object inside. Otherwise the entire complex shape is
  14348. skipped, which greatly speeds rendering.  The syntax is:
  14349.  
  14350. BOUNDED_BY:
  14351.   bounded_by { UNTEXTURED_SOLID_OBJECT... }   |   bounded_by {
  14352.   clipped_by }
  14353. Where UNTEXTURED_SOLID_OBJECT is one or more solid objects which
  14354. have had no texture applied.  For example:
  14355.  
  14356.   intersection {
  14357.     sphere { <0,0,0>, 2 }
  14358.     plane  { <0,1,0>, 0 }
  14359.     plane  { <1,0,0>, 0 }
  14360.     bounded_by { sphere { <0,0,0>, 2 } }
  14361.   }
  14362. The best bounding shape is a sphere or a box since these shapes
  14363. are highly optimized, although, any shape may be used. If the
  14364. bounding shape is itself a finite shape which responds to
  14365. bounding slabs then the object which it encloses will also be
  14366. used in the slab system.
  14367.  
  14368. While it may a good idea to manually add a bounded_by to
  14369. intersection, difference and merge, it is best to never bound a
  14370. union. If a union has no bounded_by POV-Ray can internally split
  14371. apart the components of a union and apply automatic bounding
  14372. slabs to any of its finite parts. Note that some utilities such
  14373. as raw2pov may be able to generate bounds more efficiently than
  14374. POV-Ray's current system. However most unions you create yourself
  14375. can be easily bounded by the automatic system. For technical
  14376. reasons POV-Ray cannot split a merge object. It is may be best to
  14377. hand bound a merge, especially if it is very complex.
  14378.  
  14379. Note that if bounding shape is too small or positioned
  14380. incorrectly it may clip the object in undefined ways or the
  14381. object may not appear at all. To do true clipping, use clipped_by
  14382. as explained in the previous section. Occasionally you will want
  14383. to use the clipped_by and bounded_by options with the same
  14384. object. The following shortcut saves typing and uses less memory.
  14385.  
  14386.   object {
  14387.     My_Thing
  14388.     clipped_by{ box { <0,0,0>,<1,1,1 > }}
  14389.     bounded_by{ clipped_by }
  14390.   }
  14391. This tells POV-Ray to use the same box as a bounds that was used
  14392. as a clip.
  14393.  
  14394.  
  14395. 4.5.6.3   Material
  14396. One of the changes in POV-Ray 3.1 was remove several items from
  14397. texture{finish{...}} and to move them to the new interior
  14398. statement.  The halo statement, formerly part of texture, are now
  14399. renamed media and made a part of the interior.  This split was
  14400. deliberate and purposeful (see "Why are Interior and Media
  14401. Necessary?") however beta testers have pointed out that it makes
  14402. it difficult to entirely describe the surface properties and
  14403. interior of an object in one statement that can be referenced by
  14404. a single identifier in a texture library.
  14405.  
  14406. The result is that we created a "wrapper" around texture and
  14407. interior which we call material.  The syntax is:
  14408.  
  14409. MATERIAL:
  14410.   material { [MATERIAL_IDENTIFIER][MATERIAL_ITEMS...] }
  14411. MATERIAL_ITEMS:
  14412.   TEXTURE   |   INTERIOR   |   TRANSFORMATIONS
  14413. For example:
  14414.  
  14415.   #declare MyGlass=material{texture{Glass_T} interior{Glass_I}}
  14416.   object{MyObject material{MyGlass}}
  14417. Internally, the "material" isn't attached to the object.  The
  14418. material is just a container that brings the texture and interior
  14419. to the object.  It is the texture and interior itself that is
  14420. attached to the object.  Users should still consider texture and
  14421. interior as separate items attached to the object.  The material
  14422. is just a "bucket" to carry them.
  14423.  
  14424. If the object already has a texture, the material texture is
  14425. layered over it.  If the object already has an interior, the
  14426. material interior fully replaces it and the old interior is
  14427. destroyed.
  14428.  
  14429. Transformations inside the material affect only the textures and
  14430. interiors which are inside the material{} wrapper and only those
  14431. textures or interiors specifed are affected.  For example:
  14432.  
  14433.   object{MyObject
  14434.     material{
  14435.       texture{MyTexture}
  14436.       scale 4         //affects texture but not object or
  14437. interior
  14438.       interior{MyInterior}
  14439.       translate 5*x   //affects texture and interior, not object
  14440.     }
  14441.   }
  14442. Note: The material statement has nothing to do with the
  14443. material_map statement.  A material_map is not a way to create
  14444. patterned material.  See "Material Maps" for explanation of this
  14445. unrelated, yet similarly named, older feature.
  14446.  
  14447.  
  14448. 4.5.6.4   Inverse
  14449. When using CSG it is often useful to invert an object so that
  14450. it'll be inside-out. The appearance of the object is not changed,
  14451. just the way that POV-Ray perceives it. When the inverse keyword
  14452. is used the inside of the shape is flipped to become the outside
  14453. and vice versa.  For example:
  14454.  
  14455.   object { MyObject inverse }
  14456. The inside/outside distinction is also important when attaching
  14457. interior to an object especially if media is also used.
  14458. Atmospheric media and fog also do not work as expected if your
  14459. camera is inside an object.  Using inverse is useful to correct
  14460. that problem.
  14461.  
  14462. Finally the internal_reflections and internal_highlights keywords
  14463. depend upon the inside/outside status of an object.
  14464.  
  14465.  
  14466. 4.5.6.5   Hollow
  14467. POV-Ray by default assumes that objects are made of a solid
  14468. material that completely fills the interior of an object. By
  14469. adding the hollow keyword to the object you can make it hollow.
  14470. That is very useful if you want atmospheric effects to exist
  14471. inside an object. It is even required for objects containing an
  14472. interior media.  The keyword may optionally be followed by a
  14473. float expression which is interpreted as a boolean value.  For
  14474. example hollow off may be used to force it off.  When the keyword
  14475. is specified alone, it is the same as hollow on.  The default no
  14476. hollow is specified is off.
  14477.  
  14478. In order to get a hollow CSG object you just have to make the top
  14479. level object hollow. All children will assume the same hollow
  14480. state except their state is explicitly set. The following example
  14481. will set both spheres inside the union hollow
  14482.  
  14483.   union {
  14484.     sphere { -0.5*x, 1 }
  14485.     sphere {  0.5*x, 1 }
  14486.     hollow
  14487.   }
  14488. while the next example will only set the second sphere hollow
  14489. because the first sphere was explicitly set to be not hollow.
  14490.  
  14491.   union {
  14492.     sphere { -0.5*x, 1 hollow off }
  14493.     sphere {  0.5*x, 1 }
  14494.     hollow on
  14495.   }
  14496.  
  14497. 4.5.6.6   No_Shadow
  14498. You may specify the no_shadow keyword in an object to make that
  14499. object cast no shadow. This is useful for special effects and for
  14500. creating the illusion that a light source actually is visible.
  14501. This keyword was necessary in earlier versions of POV-Ray which
  14502. did not have the looks_like statement. Now it is useful for
  14503. creating things like laser beams or other unreal effects.  During
  14504. test rendering it speeds things up if no_shadow is applied.
  14505.  
  14506. Simply attach the keyword as follows:
  14507.  
  14508.   object {
  14509.     My_Thing
  14510.     no_shadow
  14511.   }
  14512.  
  14513. 4.5.6.7   Sturm
  14514. Some of POV-Ray's objects allow you to choose between a fast but
  14515. sometimes inaccurate root solver and a slower but more accurate
  14516. one. This is the case for all objects that involve the solution
  14517. of a cubic or quartic polynomial. There are analytic mathematical
  14518. solutions for those polynomials that can be used.
  14519.  
  14520. Lower order polynomials are trivial to solve while higher order
  14521. polynomials require iterative algorithms to solve them. One of
  14522. those algorithms is the Sturmian root solver.  For example:
  14523.  
  14524.   blob {
  14525.     threshold .65
  14526.     sphere { <.5,0,0>, .8, 1 }
  14527.     sphere { <-.5,0,0>,.8, 1 }
  14528.     sturm
  14529.   }
  14530.  
  14531. The keyword may optionally be followed by a float expression
  14532. which is interpreted as a boolean value.  For example sturm off
  14533. may be used to force it off.  When the keyword is specified
  14534. alone, it is the same as sturm on.  The default no sturm is
  14535. specified is off.
  14536.  
  14537. The following list shows all objects for which the Sturmian root
  14538. solver can be used.
  14539.  
  14540.     blob
  14541.     cubic
  14542.     lathe    (only with quadratic splines)
  14543.     poly
  14544.     prism    (only with cubic splines)
  14545.     quartic
  14546.     sor
  14547.  
  14548. 4.6  Interior
  14549. New with POV-Ray 3.1 is an object modifier statement called
  14550. interior.  The syntax is:
  14551.  
  14552. INTERIOR:
  14553.   interior { [INTERIOR_IDENTIFIER] [INTERIOR_ITEMS...] }
  14554. INTERIOR_ITEM:
  14555.   ior Value   |   caustics Value   |
  14556.   fade_distance Distance   |   fade_power Power
  14557.   MEDIA...
  14558. The interior contains items which describe the properties of the
  14559. interior of the object.  This is in contrast to the texture which
  14560. describes the surface properties only.  The interior of an object
  14561. is only of interest if it has a transparent texture which allows
  14562. you to see inside the object.  It also applies only to solid
  14563. objects which have a well-defined inside/outside distinction.
  14564. Note that the open keyword, or clipped_by modifier also allows
  14565. you to see inside but interior features may not render properly.
  14566. They should be avoided if accurate interiors are required.
  14567.  
  14568. Interior identifiers may be declared to make scene files more
  14569. readable and to parameterize scenes so that changing a single
  14570. declaration changes many values. An identifier is declared as
  14571. follows.
  14572.  
  14573. INTERIOR_DECLARATION:
  14574.   #declare IDENTIFIER = INTERIOR     |
  14575.   #local IDENTIFIER = INTERIOR
  14576. Where IDENTIFIER is the name of the identifier up to 40
  14577. characters long and INTERIOR is any valid interior statement.
  14578. See "#declare vs. #local" for information on identifier scope.
  14579.  
  14580.  
  14581. 4.6.1     Why are Interior and Media Necessary?
  14582. In previous versions of POV-Ray, most of the items in the
  14583. interior statement were previously part of the finish statement.
  14584. Also the halo statement which was once part of the texture
  14585. statement has been discontinued and has been replaced by the
  14586. media statement which is part of interior.
  14587.  
  14588. You are probably asking WHY?  As explained earlier, the interior
  14589. contains items which describe the properties of the interior of
  14590. the object.  This is in contrast to the texture which describes
  14591. the surface properties only.  However this is not just a
  14592. philosophical change.  There were serious inconsistencies in the
  14593. old model.
  14594.  
  14595. The main problem arises when a texture_map or other patterned
  14596. texture is used.  These features allow you to create textures
  14597. that are a blend of two textures and which vary the entire
  14598. texture from one point to another.  It does its blending by fully
  14599. evaluating the apparent color as though only one texture was
  14600. applied and then fully reevaluating it with the other texture.
  14601. The two final results are blended.
  14602.  
  14603. It is totally illogical to have a ray enter an object with one
  14604. index or refraction and then recalculate with another index.  The
  14605. result is not an average of the two ior values.  Similarly it
  14606. makes no sense to have a ray enter at one ior and exit at a
  14607. different ior without transitioning between them along the way.
  14608. POV-Ray only calculates refraction as the ray enters or leaves.
  14609. It cannot incrementally compute a changing ior through the
  14610. interior of an object.  Real world objects such as optical fibers
  14611. or no-line bifocal eyeglasses can have variable iors but POV-Ray
  14612. cannot simulate them.
  14613.  
  14614. Similarly the halo calculations were not performed as the syntax
  14615. implied.  Using a halo in such multi-textured objects did not
  14616. vary the halo through the interior of the object.  Rather, it
  14617. computed two separate halos through the whole object and averaged
  14618. the results.  The new design for media which replaces halo makes
  14619. it possible to have media that varies throughout the interior of
  14620. the object according to a pattern but it does so independently of
  14621. the surface texture.  Because there are other changes in the
  14622. design of this feature which make it significantly different, it
  14623. was not only moved to the interior but the name was changed.
  14624.  
  14625. During our development, someone asked if we will create patterned
  14626. interiors or a hypothetical interior_map feature.  We will not.
  14627. That would defeat the whole purpose of moving these features in
  14628. the first place.  They cannot be patterned and have logical or
  14629. self-consistent results.
  14630.  
  14631.  
  14632. 4.6.2     Empty and Solid Objects
  14633. It is very important that you know the basic concept behind empty
  14634. and solid objects in POV-Ray to fully understand how features
  14635. like interior and translucency are used.  Objects in POV-Ray can
  14636. either be solid, empty or filled with (small) particles.
  14637.  
  14638. A solid object is made from the material specified by its pigment
  14639. and finish statements (and to some degree its normal statement).
  14640. By default all objects are assumed to be solid. If you assign a
  14641. stone texture to a sphere you'll get a ball made completely of
  14642. stone. It's like you had cut this ball from a block of stone. A
  14643. glass ball is a massive sphere made of glass.  You should be
  14644. aware that solid objects are conceptual things. If you clip away
  14645. parts of the sphere you'll clearly see that the interior is empty
  14646. and it just has a very thin surface.
  14647.  
  14648. This is not contrary to the concept of a solid object used in POV-
  14649. Ray. It is assumed that all space inside the sphere is covered by
  14650. the sphere's interior. Light passing through the object is
  14651. affected by attenuation and refraction properties.  However there
  14652. is no room for any other particles like those used by fog or
  14653. interior media.
  14654.  
  14655. Empty objects are created by adding the hollow keyword (see
  14656. "Hollow") to the object statement. An empty (or hollow) object is
  14657. assumed to be made of a very thin surface which is of the
  14658. material specified by the pigment, finish and normal statements.
  14659. The object's interior is empty, it normally contains air
  14660. molecules.
  14661.  
  14662. An empty object can be filled with particles by adding fog or
  14663. atmospheric media to the scene or by adding an interior media to
  14664. the object.  It is very important to understand that in order to
  14665. fill an object with  any kind of particles it first has to be
  14666. made hollow.
  14667.  
  14668. There is a pitfall in the empty/solid object implementation that
  14669. you have to be aware of.
  14670.  
  14671. In order to be able to put solid objects inside a media or fog, a
  14672. test has to be made for every ray that passes through the media.
  14673. If this ray travels through a solid object the media will not be
  14674. calculated. This is what anyone will expect. A solid glass sphere
  14675. in a fog bank does not contain fog.
  14676.  
  14677. The problem arises when the camera ray is inside any non-hollow
  14678. object. In this case the ray is already traveling through a solid
  14679. object and even if the media's container object is hit and it is
  14680. hollow, the media will not be calculated. There is no way of
  14681. telling between these two cases.
  14682.  
  14683. POV-Ray has to determine whether the camera is inside any object
  14684. prior to tracing a camera ray in order to be able to correctly
  14685. render medias when the camera is inside the container object.
  14686. There's no way around doing this.
  14687.  
  14688. The solution to this problem (that will often happen with
  14689. infinite objects like planes) is to make those objects hollow
  14690. too. Thus the ray will travel through a hollow object, will hit
  14691. the container object and the media will be calculated.
  14692.  
  14693.  
  14694. 4.6.3     Refraction
  14695. When light passes through a surface either into or out of a dense
  14696. medium the path of the ray of light is bent. Such bending is
  14697. called refraction.  The amount of bending or refracting of light
  14698. depends upon the density of the material. Air, water, crystal and
  14699. diamonds all have different densities and thus refract
  14700. differently. The index of refraction or ior value is used by
  14701. scientists to describe the relative density of substances. The
  14702. ior keyword is used in POV-Ray in the interior to turn on
  14703. refraction and to specify the ior value. For example:
  14704.  
  14705.   object{ MyObject pigment{Clear} interior{ior 1.5}}
  14706. The default ior value of 1.0 will give no refraction. The index
  14707. of refraction for air is 1.0, water is 1.33, glass is 1.5 and
  14708. diamond is 2.4.
  14709.  
  14710. Normally transparent or semi-transparent surfaces in POV-Ray do
  14711. not refract light. Earlier versions of POV-Ray required you to
  14712. use the refraction keyword in the finish statement to turn on
  14713. refraction.  This is no longer necessary.  Any non-zero ior value
  14714. now turns refraction on.
  14715.  
  14716. In addition to turning refraction on or off, the old refraction
  14717. keyword was followed by a float value from 0.0 to 1.0.  Values in
  14718. between 0.0 and 1.0 would darken the refracted light in ways that
  14719. do not correspond to any physical property. Many POV-Ray scenes
  14720. were created with intermediate refraction values before this bug
  14721. was discovered so the feature has been maintained. A more
  14722. appropriate way to reduce the brightness of refracted light is to
  14723. change the filter or transmit value in the colors specified in
  14724. the pigment statement or to use the fade_power and fade_distance
  14725. keywords.  See "Attenuation". Note also that neither the ior nor
  14726. refraction keywords cause the object to be transparent.
  14727. Transparency only occurs if there is a non-zero filter or
  14728. transmit value in the color.
  14729.  
  14730. The refraction and ior keywords were original specified in finish
  14731. but are now properly specified in interior.  They are accepted in
  14732. finish for backward compatibility and generate a warning message.
  14733.  
  14734.  
  14735. 4.6.4     Attenuation
  14736. Light attenuation is used to model the decrease in light
  14737. intensity as the light travels through a transparent object.  The
  14738. keywords fade_power Fade_Power and fade_distance Fade_Distance
  14739. keywords are specified in the interior statement.
  14740.  
  14741. The fade_distance value determines the distance the light has to
  14742. travel to reach half intensity while the fade_power value
  14743. determines how fast the light will fall off. For realistic
  14744. effects a fade power of 1 to 2 should be used.  Default values
  14745. for both keywords is 0.0 which turns this feature off.
  14746.  
  14747. The attenuation is calculated by a formula similar to that used
  14748. for light source attenuation.
  14749.  
  14750.                                 
  14751.                                 
  14752. The fade_power and fade_distance keywords were original specified
  14753. in finish but are now properly specified in interior.  They are
  14754. accepted in finish for backward compatibility and generate a
  14755. warning message.
  14756.  
  14757.  
  14758. 4.6.5     Faked Caustics
  14759. Caustics are light effects that occur if light is reflected or
  14760. refracted by specular reflective or refractive surfaces. Imagine
  14761. a glass of water standing on a table. If sunlight falls onto the
  14762. glass you will see spots of light on the table. Some of the spots
  14763. are caused by light being reflected by the glass while some of
  14764. them are caused by light being refracted by the water in the
  14765. glass.
  14766.  
  14767. Since it is a very difficult and time-consuming process to
  14768. actually calculate those effects (though it is not impossible)
  14769. POV-Ray uses a quite simple method to simulate caustics caused by
  14770. refraction. The method calculates the angle between the incoming
  14771. light ray and the surface normal.  Where they are nearly parallel
  14772. it makes the shadow brighter.  Where the angle is greater, the
  14773. effect is diminished.  Unlike real-world caustics, the effect
  14774. does not vary based on distance.  This caustic effect is limited
  14775. to areas that are shaded by the transparent object. You'll get no
  14776. caustic effects from reflective surfaces nor in parts that are
  14777. not shaded by the object.
  14778.  
  14779. The caustics Power keyword controls the effect.  Values typically
  14780. range from 0.0 to 1.0 or higher.  Zero is the default which is no
  14781. caustics.  Low, non-zero values give broad hot-spots while higher
  14782. values give tighter, smaller simulated focal points.
  14783.  
  14784. The caustics keyword was originally specified in finish but is
  14785. now properly specified in interior.  It is accepted in finish for
  14786. backward compatibility and generates a warning message.
  14787.  
  14788.  
  14789. 4.6.6     Object Media
  14790. The interiorstatement may contain one or more media statements.
  14791. Media is used to simulate suspended particles such as smoke,
  14792. haze, or dust.  Or visible gasses such as steam or fire and
  14793. explosions.  When used with an object interior, the effect is
  14794. constrained by the object's shape.  The calculations begin when
  14795. the ray enters an object and ends when it leaves the object.
  14796. This section only discusses media when used with object interior.
  14797. The complete syntax and an explanation of all of the parameters
  14798. and options for media is given in the section "Media".
  14799.  
  14800. Typically the object itself is given a fully transparent texture
  14801. however media also works in partially transparent objects.  The
  14802. texture pattern itself does not effect the interior media except
  14803. perhaps to create shadows on it.  The texture pattern of an
  14804. object applies only to the surface shell.  Any interior media
  14805. patterns are totally independent of the texture.
  14806.  
  14807. In previous versions of POV-Ray, this feature was called halo and
  14808. was part of the texture specification along with pigment, normal,
  14809. and finish.  See "Why are Interior and Media Necessary?" for an
  14810. explanation of the reasons for the change.
  14811.  
  14812. Note a strange design side-effect was discovered during testing
  14813. and it was too difficult to fix.  If the enclosing object uses
  14814. transmit rather than filter for transparency, then the media
  14815. casts no shadows.  For example:
  14816.  
  14817.  object{MyObject pigment{rgbt 1.0} interior{media{MyMedia}}} //no
  14818. shadows
  14819.  object{MyObject pigment{rgbf 1.0} interior{media{MyMedia}}}
  14820. //shadows
  14821. Media may also be specified outside an object to simulate
  14822. atmospheric media.  There is no constraining object in this case.
  14823. If you only want media effects in a particular area, you should
  14824. use object media rather than only relying upon the media pattern.
  14825. In general it will be faster and more accurate because it only
  14826. calculates inside the constraining object.  See "Atmospheric
  14827. Media" for details on unconstrained uses of media.
  14828.  
  14829. You may specify more than one media statement per interior
  14830. statement.  In that case, all of the media participate and where
  14831. they overlap, they add together.
  14832.  
  14833. Any object which is supposed to have media effects inside it,
  14834. whether those effects are object media or atmospheric media, must
  14835. have the hollow on keyword applied.  Otherwise the media is
  14836. blocked.  See "Empty and Solid Objects" for details.
  14837.  
  14838.  
  14839. 4.7  Textures
  14840. The texture statement is an object modifier which describes what
  14841. the surface of an object looks like, i.e. its material. Textures
  14842. are combinations of pigments, normals, and finishes. Pigment is
  14843. the color or pattern of colors inherent in the material. Normal
  14844. is a method of simulating various patterns of bumps, dents,
  14845. ripples or waves by modifying the surface normal vector. Finish
  14846. describes the reflective properties of a material.
  14847.  
  14848. Note that in previous versions of POV-Ray, the texture also
  14849. contained information about the interior of an object.  This
  14850. information has been moved to a separate object modifier called
  14851. interior.  See "Interior" for details.
  14852.  
  14853. There are three basic kinds of textures: plain, patterned, and
  14854. layered. A plain texture consists of a single pigment, an
  14855. optional normal, and a single finish. A patterned texture
  14856. combines two or more textures using a block pattern or blending
  14857. function pattern.  Patterned textures may be made quite complex
  14858. by nesting patterns within patterns. At the innermost levels
  14859. however, they are made up from plain textures. A layered texture
  14860. consists of two or more semi-transparent textures layered on top
  14861. of one another. Note that although we call a plain texture plain
  14862. it may be a very complex texture with patterned pigments and
  14863. normals. The term plain only means that it has a single pigment,
  14864. normal, and finish.
  14865.  
  14866. The syntax for texture is as follows:
  14867.  
  14868. TEXTURE:
  14869.   PLAIN_TEXTURE   |   PATTERNED_TEXTURE   |   LAYERED_TEXTURE
  14870. PLAIN_TEXTURE:
  14871.   texture { [TEXTURE_IDENTIFIER] [PNF_IDENTIFIER...]
  14872.   [PNF_ITEMS...] }
  14873. PNF_IDENTIFIER:
  14874.   PIGMENT_IDENTIFIER   |   NORMAL_IDENTIFIER   |
  14875.   FINISH_IDENTIFIER
  14876. PNF_ITEMS:
  14877.   PIGMENT   |   NORMAL   |   FINISH   |   TRANSFORMATION
  14878. LAYERED_TEXTURE:
  14879.   NON_PATTERNED_TEXTURE...
  14880. PATTERNED_TEXTURE:
  14881.   texture { [PATTERNED_TEXTURE_ID] [TRANSFORMATIONS...] }   |
  14882.   texture { PATTERN_TYPE [TEXTURE_PATTERN_MODIFIERS...] }   |
  14883.   texture { tiles TEXTURE  tile2 TEXTURE [TRANSFORMATIONS...] }
  14884.   |
  14885.   texture {
  14886.      material_map{
  14887.        BITMAP_TYPE "bitmap.ext" [MATERIAL_MODS...] TEXTURE...
  14888.      [TRANSFORMATIONS...]
  14889.      }
  14890.   }
  14891. TEXTURE_PATTERN_MODIFIER:
  14892.   PATTERN_MODIFIER   |   TEXTURE_LIST   |
  14893.   texture_map{ TEXTURE_MAP_BODY }
  14894. In the PLAIN_TEXTURE, each of the items are optional but if they
  14895. are present the TEXTURE_IDENTIFIER must be first. If no texture
  14896. identifier is given, then POV-Ray creates a copy of the default
  14897. texture.  See "The #default Directive" for details.
  14898.  
  14899. Next are optional pigment, normal, and/or finish identifiers
  14900. which fully override the any pigment, normal and finish already
  14901. specified in the previous texture identifier or default texture.
  14902. Typically this is used for backward compatibility to allow things
  14903. like: texture{MyPigment} where MyPigment is a pigment identifier.
  14904.  
  14905. Finally we have optional pigment, normal or finish statements
  14906. which modify any pigment, normal and finish already specified in
  14907. the identifier. If no texture identifier is specified the
  14908. pigment, normal and finish statements modify the current default
  14909. values. This is the typical plain texture:
  14910.  
  14911.   texture{
  14912.     pigment{MyPigment}
  14913.     normal{MyNormal}
  14914.     finish{MyFinish}
  14915.     scale SoBig
  14916.     rotate SoMuch
  14917.     translate SoFar
  14918. }
  14919. The TRANSFORMATIONS may be interspersed between the pigment,
  14920. normal and finish statements but are generally specified last.
  14921. If they are interspersed, then they modify only those parts of
  14922. the texture already specified.  For example:
  14923.  
  14924.   texture{
  14925.     pigment{MyPigment}
  14926.     scale SoBig        //affects pigment only
  14927.     normal{MyNormal}
  14928.     rotate SoMuch      //affects pigment and normal
  14929.     finish{MyFinish}
  14930.     translate SoFar    //finish is never transformable no matter
  14931. what.
  14932.                        //Therefore affects pigment and normal
  14933. only
  14934. }
  14935. Texture identifiers may be declared to make scene files more
  14936. readable and to parameterize scenes so that changing a single
  14937. declaration changes many values. An identifier is declared as
  14938. follows.
  14939.  
  14940. TEXTURE_DECLARATION:
  14941.   #declare IDENTIFIER = TEXTURE    |
  14942.   #local IDENTIFIER = TEXTURE
  14943. Where IDENTIFIER is the name of the identifier up to 40
  14944. characters long and TEXTURE is any valid texture statement.  See
  14945. "#declare vs. #local" for information on identifier scope.
  14946.  
  14947. The sections below describe all of the options available in
  14948. "Pigment", "Normal", and "Finish" which are the main part of
  14949. plain textures.. There are also separate sections for "Patterned
  14950. Textures" and "Layered Textures" which are made up of plain
  14951. textures.  Note that the tiles and material_map versions of
  14952. patterned textures are obsolete and are only supported for
  14953. backwards compatibility.
  14954.  
  14955.  
  14956. 4.7.1     Pigment
  14957. The color or pattern of colors for an object is defined by a
  14958. pigment statement. All plain textures must have a pigment. If you
  14959. do not specify one the default pigment is used.  The color you
  14960. define is the way you want the object to look if fully
  14961. illuminated. You pick the basic color inherent in the object and
  14962. POV-Ray brightens or darkens it depending on the lighting in the
  14963. scene. The parameter is called pigment because we are defining
  14964. the basic color the object actually is rather than how it looks.
  14965.  
  14966. The syntax for pigment is:
  14967.  
  14968. PIGMENT:
  14969.   pigment{ [PIGMENT_IDENTIFIER] [PIGMENT_TYPE]
  14970.   [PIGMENT_MODIFIER...] }
  14971. PIGMENT_TYPE:
  14972.   PATTERN_TYPE   |
  14973.   COLOR   |
  14974.   image_map{ BITMAP_TYPE "bitmap.ext" [IMAGE_MAP_MODS...] }
  14975. PIGMENT_MODIFIER:
  14976.   PATTERN_MODIFIER   |   COLOR_LIST   |   PIGMENT_LIST   |
  14977.   color_map{ COLOR_MAP_BODY }   |   colour_map{ COLOR_MAP_BODY }
  14978.   |
  14979.   pigment_map{ PIGMENT_MAP_BODY }   |
  14980.   quick_color COLOR   |   quick_colour COLOR
  14981. Each of the items in a pigment are optional but if they are
  14982. present, they must be in the order shown. Any items after the
  14983. PIGMENT_IDENTIFIER modify or override settings given in the
  14984. identifier. If no identifier is specified then the items modify
  14985. the pigment values in the current default texture. The
  14986. PIGMENT_TYPE  fall into roughly four categories. Each category is
  14987. discussed the sub-sections which follow. The four categories are
  14988. solid color and image map patterns which are specific to pigment
  14989. statements or color list patterns, color mapped patterns which
  14990. use POV-Ray's wide selection of general patterns.  See "Patterns"
  14991. for details about specific patterns.
  14992.  
  14993. The pattern type is optionally followed by one or more pigment
  14994. modifiers.  In addition to general pattern modifiers such as
  14995. transformations, turbulence, and warp modifiers, pigments may
  14996. also have a COLOR_LIST, PIGMENT_LIST, color_map, pigment_map, and
  14997. quick_color which are specific to pigments.  See "Pattern
  14998. Modifiers" for information on general modifiers.  The pigment-
  14999. specific modifiers are described in sub-sections which follow.
  15000. Pigment modifiers of any kind apply only to the pigment and not
  15001. to other parts of the texture. Modifiers must be specified last.
  15002.  
  15003. A pigment statement is part of a texture specification.  However
  15004. it can be tedious to use a texture statement just to add a color
  15005. to an object. Therefore you may attach a pigment directly to an
  15006. object without explicitly specifying that it as part of a
  15007. texture. For example instead of this:
  15008.  
  15009.   object {My_Object texture{pigment{color Red}}}
  15010. you may shorten it to:
  15011.  
  15012.   object {My_Object pigment{color Red}}
  15013. Note however that doing so creates an entire texture structure
  15014. with default normal and finish statements just as if you had
  15015. explicitly typed the full texture{...} around it.
  15016.  
  15017. Pigment identifiers may be declared to make scene files more
  15018. readable and to parameterize scenes so that changing a single
  15019. declaration changes many values. An identifier is declared as
  15020. follows.
  15021.  
  15022. PIGMENT_DECLARATION:
  15023.   #declare IDENTIFIER = PIGMENT   |
  15024.   #local IDENTIFIER = PIGMENT
  15025. Where IDENTIFIER is the name of the identifier up to 40
  15026. characters long and PIGMENT is any valid pigment statement.  See
  15027. "#declare vs. #local" for information on identifier scope.
  15028.  
  15029.  
  15030. 4.7.1.1   Solid Color Pigments
  15031. The simplest type of pigment is a solid color. To specify a solid
  15032. color you simply put a color specification inside a pigment
  15033. statement. For example:
  15034.  
  15035.   pigment {color Orange}
  15036. A color specification consists of the optional keyword color
  15037. followed by a color identifier or by a specification of the
  15038. amount of red, green, blue, filtered and unfiltered transparency
  15039. in the surface. See section "Specifying Colors" for more details
  15040. about colors. Any pattern modifiers used with a solid color are
  15041. ignored because there is no pattern to modify.
  15042.  
  15043.  
  15044. 4.7.1.2   Color List Pigments
  15045. There are three color list patterns: checker, hexagon and brick.
  15046. The result is a pattern of solid colors with distinct edges
  15047. rather than a blending of colors as with color mapped patterns.
  15048. Each of these patterns is covered in more detail in a later
  15049. section. The syntax is:
  15050.  
  15051. COLOR_LIST_PIGMENT:
  15052.   pigment{brick [COLOR_1, [COLOR_2]] [PIGMENT_MODIFIERS...] }
  15053.   |
  15054.   pigment{checker [COLOR_1, [COLOR_2]] [PIGMENT_MODIFIERS...] }
  15055.   |
  15056.   pigment{hexagon [COLOR_1, [COLOR_2, [COLOR_3]]]
  15057.   [PIGMENT_MODIFIERS...] }
  15058. Each COLOR_n is any valid color specification. There should be a
  15059. comma between each color or the color keyword should be used as a
  15060. separator so that POV-Ray can determine where each color
  15061. specification starts and ends. The brick and checker pattern
  15062. expects two colors and hexagon expects three.  If an insufficient
  15063. number of colors is specified then default colors are used.
  15064.  
  15065.  
  15066. 4.7.1.3   Color Maps
  15067. Most of the color patterns do not use abrupt color changes of
  15068. just two or three colors like those in the brick, checker or
  15069. hexagon patterns.  They instead use smooth transitions of many
  15070. colors that gradually change from one point to the next. The
  15071. colors are defined in a pigment modifier called a color_map that
  15072. describes how the pattern blends from one color to the next.
  15073.  
  15074. Each of the various pattern types available is in fact a
  15075. mathematical function that takes any x, y, z location and turns
  15076. it into a number between 0.0 and 1.0 inclusive. That number is
  15077. used to specify what mix of colors to use from the color map.
  15078.  
  15079. The syntax for color_map is as follows:
  15080.  
  15081. COLOR_MAP:
  15082.   color_map{ COLOR_MAP_BODY }   |   colour_map{ COLOR_MAP_BODY }
  15083. COLOR_MAP_BODY:
  15084.   COLOR_MAP_IDENTIFIER   |   COLOR_MAP_ENTRY...
  15085. COLOR_MAP_ENTRY:
  15086.   [ Value  COLOR ]   |   [ Value_1, Value_2 color COLOR_1 color
  15087.   COLOR_2 ]
  15088. Where each Value_n is a float values between 0.0 and 1.0
  15089. inclusive and each COLOR_n, is color specifications. Note that
  15090. the [] brackets are part of the actual COLOR_MAP_ENTRY. They are
  15091. not notational symbols denoting optional parts. The brackets
  15092. surround each entry in the color map. There may be from 2 to 256
  15093. entries in the map. The alternate spelling colour_map may be
  15094. used.
  15095.  
  15096. Here is an example:
  15097.  
  15098.   sphere {
  15099.     <0,1,2>, 2
  15100.     pigment {
  15101.       gradient x       //this is the PATTERN_TYPE
  15102.       color_map {
  15103.         [0.1  color Red]
  15104.         [0.3  color Yellow]
  15105.         [0.6  color Blue]
  15106.         [0.6  color Green]
  15107.         [0.8  color Cyan]
  15108.       }
  15109.     }
  15110.   }
  15111. The pattern function gradient x is evaluated and the result is a
  15112. value from 0.0 to 1.0. If the value is less than the first entry
  15113. (in this case 0.1) then the first color (red) is used. Values
  15114. from 0.1 to 0.3 use a blend of red and yellow using linear
  15115. interpolation of the two colors. Similarly values from 0.3 to 0.6
  15116. blend from yellow to blue. Note that the 3rd and 4th entries both
  15117. have values of 0.6. This causes an immediate abrupt shift of
  15118. color from blue to green. Specifically a value that is less than
  15119. 0.6 will be blue but exactly equal to 0.6 will be green. Moving
  15120. along, values from 0.6 to 0.8 will be a blend of green and cyan.
  15121. Finally any value greater than or equal to 0.8 will be cyan.
  15122.  
  15123. If you want areas of unchanging color you simply specify the same
  15124. color for two adjacent entries. For example:
  15125.  
  15126.   color_map {
  15127.     [0.1  color Red]
  15128.     [0.3  color Yellow]
  15129.     [0.6  color Yellow]
  15130.     [0.8  color Green]
  15131.   }
  15132. In this case any value from 0.3 to 0.6 will be pure yellow.
  15133.  
  15134. The first syntax version of COLOR_MAP_ENTRY with one float and
  15135. one color is the current standard.  The other double entry
  15136. version is obsolete and should be avoided.  The previous example
  15137. would look as follows using the old syntax.
  15138.  
  15139.   color_map {
  15140.     [0.0 0.1  color Red color Red]
  15141.     [0.1 0.3  color Red color Yellow]
  15142.     [0.3 0.6  color Yellow color Yellow]
  15143.     [0.6.0.8  color Yellow color Green]
  15144.     [0.8 1.0  color Green color Green]
  15145.   }
  15146. You may use color_map with any patterns except brick, checker,
  15147. hexagon and image_map. You may declare and use color_map
  15148. identifiers. For example:
  15149.  
  15150.   #declare Rainbow_Colors=
  15151.     color_map {
  15152.       [0.0   color Magenta]
  15153.       [0.33  color Yellow]
  15154.       [0.67  color Cyan]
  15155.       [1.0   color Magenta]
  15156.     }
  15157.   object{My_Object
  15158.     pigment{
  15159.       gradient x
  15160.       color_map{Rainbow_Colors}
  15161.     }
  15162.   }
  15163.  
  15164. 4.7.1.4   Pigment Maps and Pigment Lists
  15165. In addition to specifying blended colors with a color map you may
  15166. create a blend of pigments using a pigment_map. The syntax for a
  15167. pigment map is identical to a color map except you specify a
  15168. pigment in each map entry (and not a color).
  15169.  
  15170. The syntax for pigment_map is as follows:
  15171.  
  15172. PIGMENT_MAP:
  15173.   pigment_map{ PIGMENT_MAP_BODY }
  15174. PIGMENT_MAP_BODY:
  15175.   PIGMENT_MAP_IDENTIFIER   |   PIGMENT_MAP_ENTRY...
  15176. PIGMENT_MAP_ENTRY:
  15177.   [ Value  PIGMENT_BODY ]
  15178. Where Value is a float value between 0.0 and 1.0 inclusive and
  15179. each PIGMENT_BODY is anything which can be inside a pigment{...}
  15180. statement.  The pigment keyword and {} braces need not be
  15181. specified.
  15182.  
  15183. Note that the [] brackets are part of the actual
  15184. PIGMENT_MAP_ENTRY. They are not notational symbols denoting
  15185. optional parts. The brackets surround each entry in the pigment
  15186. map. There may be from 2 to 256 entries in the map.
  15187.  
  15188. For example
  15189.  
  15190.   sphere {
  15191.     <0,1,2>, 2
  15192.     pigment {
  15193.       gradient x       //this is the PATTERN_TYPE
  15194.       pigment_map {
  15195.         [0.3 wood scale 0.2]
  15196.         [0.3 Jade]    //this is a pigment identifier
  15197.         [0.6 Jade]
  15198.         [0.9 marble turbulence 1]
  15199.       }
  15200.     }
  15201.   }
  15202. When the gradient x function returns values from 0.0 to 0.3 the
  15203. scaled wood pigment is used. From 0.3 to 0.6 the pigment
  15204. identifier Jade is used. From 0.6 up to 0.9 a blend of Jade and a
  15205. turbulent marble is used. From 0.9 on up only the turbulent
  15206. marble is used.
  15207.  
  15208. Pigment maps may be nested to any level of complexity you desire.
  15209. The pigments in a map may have color maps or pigment maps or any
  15210. type of pigment you want. Any entry of a pigment map may be a
  15211. solid color however if all entries are solid colors you should
  15212. use a color_map which will render slightly faster.
  15213.  
  15214. Entire pigments may also be used with the block patterns such as
  15215. checker, hexagon and brick. For example...
  15216.  
  15217.   pigment {
  15218.     checker
  15219.     pigment { Jade scale .8 }
  15220.     pigment { White_Marble scale .5 }
  15221.   }
  15222. Note that in the case of block patterns the pigment wrapping is
  15223. required around the pigment information.
  15224.  
  15225. A pigment map is also used with the average pigment type. See
  15226. "Average" for details.
  15227.  
  15228. You may not use pigment_map or individual pigments with an
  15229. image_map. See section "Texture Maps" for an alternative way to
  15230. do this.
  15231.  
  15232. You may declare and use pigment map identifiers but the only way
  15233. to declare a pigment block pattern list is to declare a pigment
  15234. identifier for the entire pigment.
  15235.  
  15236.  
  15237. 4.7.1.5   Image Maps
  15238. When all else fails and none of the above pigment pattern types
  15239. meets your needs you can use an image_map to wrap a 2-D bit-
  15240. mapped image around your 3-D objects.
  15241.  
  15242.  
  15243. 4.7.1.5.1 Specifying an Image Map
  15244. The syntax for an image_map is:
  15245.  
  15246. IMAGE_MAP:
  15247.   pigment{
  15248.      image_map{ BITMAP_TYPE "bitmap.ext" [IMAGE_MAP_MODS...] }
  15249.      [PIGMENT_MODFIERS...]
  15250.   }
  15251. BITMAP_TYPE:
  15252.   gif   |   tga   |   iff   |   ppm   |   pgm   |   png   |
  15253.   sys
  15254. IMAGE_MAP_MOD:
  15255.   map_type  Type   |   once   |   interpolate  Type   |
  15256.   filter Palette, Amount   |   filter all Amount   |
  15257.   transmit Palette, Amount   |   transmit all Amount
  15258. After the required BITMAP_TYPE keyword is a string expression
  15259. containing the name of a bitmapped image file of the specified
  15260. type.  Several optional modifiers may follow the file
  15261. specification. The modifiers are described below. Note that
  15262. earlier versions of POV-Ray allowed some modifiers before the
  15263. BITMAP_TYPE but that syntax is being phased out in favor of the
  15264. syntax described here.  Note sys format is a system-specific
  15265. format such as BMP for Windows or Pict for Macintosh.
  15266.  
  15267. Filenames specified in the image_map statements will be searched
  15268. for in the home (current) directory first and, if not found, will
  15269. then be searched for in directories specified by any +L or
  15270. Library_Path options active. This would facilitate keeping all
  15271. your image maps files in a separate subdirectory and giving a
  15272. Library_Path option to specify where your library of image maps
  15273. are.  See "Library Paths" for details.
  15274.  
  15275. By default, the image is mapped onto the x-y-plane. The image is
  15276. projected onto the object as though there were a slide projector
  15277. somewhere in the -z-direction. The image exactly fills the square
  15278. area from (x,y) coordinates (0,0) to (1,1) regardless of the
  15279. image's original size in pixels. If you would like to change this
  15280. default you may translate, rotate or scale the pigment or texture
  15281. to map it onto the object's surface as desired.
  15282.  
  15283. In the section "Checker", the checker pigment pattern is
  15284. explained. The checks are described as solid cubes of colored
  15285. clay from which objects are carved. With image maps you should
  15286. imagine that each pixel is a long, thin, square, colored rod that
  15287. extends parallel to the z-axis. The image is made from rows and
  15288. columns of these rods bundled together and the object is then
  15289. carved from the bundle.
  15290.  
  15291. If you would like to change this default orientation you may
  15292. translate, rotate or scale the pigment or texture to map it onto
  15293. the object's surface as desired.
  15294.  
  15295. The file name is optionally followed by one or more
  15296. BITMAP_MODIFIERS.  The filter, filter all, transmit, and transmit
  15297. all modifiers are specific to image maps and are discussed in the
  15298. following sections.  An image_map may also use generic bitmap
  15299. modifiers map_type, once and interpolate described in "Bitmap
  15300. Modifiers"
  15301.  
  15302.  
  15303. 4.7.1.5.2 The Filter and Transmit Bitmap Modifiers
  15304. To make all or part of an image map transparent you can specify
  15305. filter and/or transmit values for the color palette/registers of
  15306. PNG, GIF or IFF pictures (at least for the modes that use
  15307. palettes). You can do this by adding the keyword filter or
  15308. transmit following the filename. The keyword is followed by two
  15309. numbers. The first number is the palette number value and the
  15310. second is the amount of transparency. The values should be
  15311. separated by a comma. For example:
  15312.  
  15313.   image_map {
  15314.     gif "mypic.gif"
  15315.     filter   0, 0.5 // Make color 0 50% filtered transparent
  15316.     filter   5, 1.0 // Make color 5 100% filtered transparent
  15317.     transmit 8, 0.3 // Make color 8 30% non-filtered transparent
  15318.   }
  15319. You can give the entire image a filter or transmit value using
  15320. filter all Amount or transmit all Amount. For example:
  15321.  
  15322.   image_map {
  15323.     gif "stnglass.gif"
  15324.     filter all 0.9
  15325.   }
  15326. Note that early versions of POV-Ray used the keyword alpha to
  15327. specify filtered transparency however that word is often used to
  15328. describe non-filtered transparency. For this reason alpha is no
  15329. longer used.
  15330.  
  15331. See section "Specifying Colors" for details on the differences
  15332. between filtered and non-filtered transparency.
  15333.  
  15334.  
  15335. 4.7.1.5.3 Using the Alpha Channel
  15336. Another way to specify non-filtered transmit transparency in an
  15337. image map is by using the alpha channel.  PNG file format allows
  15338. you to store a different transparency for each color index in the
  15339. PNG file, if desired. If your paint programs support this feature
  15340. of PNG you can do the transparency editing within your paint
  15341. program rather than specifying transmit values for each color in
  15342. the POV file. Since PNG and TGA image formats can also store full
  15343. alpha channel (transparency) information you can generate image
  15344. maps that have transparency which isn't dependent on the color of
  15345. a pixel but rather its location in the image.
  15346.  
  15347. Although POV uses transmit 0.0 to specify no transparency and 1.0
  15348. to specify full transparency, the alpha data ranges from 0 to 255
  15349. in the opposite direction. Alpha data 0 means the same as
  15350. transmit 1.0 and alpha data 255 produces transmit 0.0.
  15351.  
  15352.  
  15353. 4.7.1.6   Quick Color
  15354. When developing POV-Ray scenes its often useful to do low quality
  15355. test runs that render faster. The +Q command line switch or
  15356. Quality INI option can be used to turn off some time consuming
  15357. color pattern and lighting calculations to speed things up. See
  15358. "Quality Settings" for details.  However all settings of +Q5 or
  15359. Quality=5 or lower turns off pigment calculations and creates
  15360. gray objects.
  15361.  
  15362. By adding a quick_color to a pigment you tell POV-Ray what solid
  15363. color to use for quick renders instead of a patterned pigment.
  15364. For example:
  15365.  
  15366.   pigment {
  15367.     gradient x
  15368.     color_map{
  15369.       [0.0 color Yellow]
  15370.       [0.3 color Cyan]
  15371.       [0.6 color Magenta]
  15372.       [1.0 color Cyan]
  15373.     }
  15374.     turbulence 0.5
  15375.     lambda 1.5
  15376.     omega 0.75
  15377.     octaves 8
  15378.     quick_color Neon_Pink
  15379.   }
  15380. This tells POV-Ray to use solid Neon_Pink for test runs at
  15381. quality +Q5 or lower but to use the turbulent gradient pattern
  15382. for rendering at +Q6 and higher.
  15383.  
  15384. Note that solid color pigments such as
  15385.  
  15386.   pigment {color Magenta}
  15387. automatically set the quick_color to that value. You may override
  15388. this if you want. Suppose you have 10 spheres on the screen and
  15389. all are yellow. If you want to identify them individually you
  15390. could give each a different quick_color like this:
  15391.  
  15392.   sphere {
  15393.     <1,2,3>,4
  15394.     pigment { color Yellow  quick_color Red }
  15395.   }
  15396.   sphere {
  15397.     <-1,-2,-3>,4
  15398.     pigment { color Yellow  quick_color Blue }
  15399.   }
  15400. and so on. At +Q6 or higher they will all be yellow but at +Q5 or
  15401. lower each would be different colors so you could identify them.
  15402.  
  15403. The alternate spelling quick_colour is also supported.
  15404.  
  15405.  
  15406. 4.7.2     Normal
  15407. Ray-tracing is known for the dramatic way it depicts reflection,
  15408. refraction and lighting effects. Much of our perception depends
  15409. on the reflective properties of an object. Ray tracing can
  15410. exploit this by playing tricks on our perception to make us see
  15411. complex details that aren't really there.
  15412.  
  15413. Suppose you wanted a very bumpy surface on the object. It would
  15414. be very difficult to mathematically model lots of bumps. We can
  15415. however simulate the way bumps look by altering the way light
  15416. reflects off of the surface. Reflection calculations depend on a
  15417. vector called a surface normal vector. This is a vector which
  15418. points away from the surface and is perpendicular to it. By
  15419. artificially modifying (or perturbing) this normal vector you can
  15420. simulate bumps.  This is done by adding an optional normal
  15421. statement.
  15422.  
  15423. Note that attaching a normal pattern does not really modify the
  15424. surface. It only affects the way light reflects or refracts at
  15425. the surface so that it looks bumpy.  The syntax is:
  15426.  
  15427. NORMAL:
  15428.   normal{ [NORMAL_IDENTIFIER] [NORMAL_TYPE] [NORMAL_MODIFIER...]
  15429.   }
  15430. NORMAL_TYPE:
  15431.   PATTERN_TYPE Amount   |
  15432.   bump_map{ BITMAP_TYPE "bitmap.ext" [BUMP_MAP_MODS...] }
  15433. NORMAL_MODIFIER:
  15434.   PATTERN_MODIFIER   |   NORMAL_LIST   |
  15435.   normal_map{ NORMAL_MAP_BODY }   |
  15436.   slope_map{ SLOPE_MAP_BODY }   |
  15437.   bump_size Amount
  15438. Each of the items in a normal are optional but if they are
  15439. present, they must be in the order shown. Any items after the
  15440. NORMAL_IDENTIFIER modify or override settings given in the
  15441. identifier. If no identifier is specified then the items modify
  15442. the normal values in the current default texture. The
  15443. PATTERN_TYPE may optionally be followed by a float value that
  15444. controls the apparent depth of the bumps. Typical values range
  15445. from 0.0 to 1.0 but any value may be used. Negative values invert
  15446. the pattern. The default value if none is specified is 0.5.
  15447.  
  15448. There are four basic types of NORMAL_TYPEs. They are block
  15449. pattern normals, continuous pattern normals, specialized normals
  15450. and bump maps. They differ in the types of modifiers you may use
  15451. with them. The pattern type is optionally followed by one or more
  15452. normal modifiers.  In addition to general pattern modifiers such
  15453. as transformations, turbulence, and warp modifiers, normals may
  15454. also have a NORMAL_LIST, slope_map, normal_map, and
  15455. bump_sizewhich are specific to normals.  See "Pattern Modifiers"
  15456. for information on general modifiers.  The normal-specific
  15457. modifiers are described in sub-sections which follow.  Normal
  15458. modifiers of any kind apply only to the normal and not to other
  15459. parts of the texture. Modifiers must be specified last.
  15460.  
  15461. Originally POV-Ray had some patterns which were exclusively used
  15462. for pigments while others were exclusively used for normals.
  15463. Since POV-Ray 3.0 you can use any pattern for either pigments or
  15464. normals. For example it is now valid to use ripples as a pigment
  15465. or wood as a normal type. The patterns bumps, dents, ripples,
  15466. waves, wrinkles, and bump_map were once exclusively normal
  15467. patterns which could not be used as pigments. Because these six
  15468. types use specialized normal modification calculations they
  15469. cannot have slope_map, normal_map or wave shape modifiers. All
  15470. other normal pattern types may use them.  Because block patterns
  15471. checker, hexagon, and brick do not return a continuous series of
  15472. values, they cannot use these modifiers either.  See "Patterns"
  15473. for details about specific patterns.
  15474.  
  15475. A normal statement is part of a texture specification.  However
  15476. it can be tedious to use a texture statement just to add a bumps
  15477. to an object. Therefore you may attach a normal directly to an
  15478. object without explicitly specifying that it as part of a
  15479. texture. For example instead of this:
  15480.  
  15481.   object {My_Object texture{normal{bumps 0.5}}}
  15482. you may shorten it to:
  15483.  
  15484.   object {My_Object normal{bumps 0.5}}
  15485. Note however that doing so creates an entire texture structure
  15486. with default pigment and finish statements just as if you had
  15487. explicitly typed the full texture{...} around it.
  15488.  
  15489. Normal identifiers may be declared to make scene files more
  15490. readable and to parameterize scenes so that changing a single
  15491. declaration changes many values. An identifier is declared as
  15492. follows.
  15493.  
  15494. NORMAL_DECLARATION:
  15495.   #declare IDENTIFIER = NORMAL   |
  15496.   #local IDENTIFIER = NORMAL
  15497. Where IDENTIFIER is the name of the identifier up to 40
  15498. characters long and NORMAL is any valid normal statement.  See
  15499. "#declare vs. #local" for information on identifier scope.
  15500.  
  15501.  
  15502. 4.7.2.1   Slope Maps
  15503. A slope_map is a normal pattern modifier which gives the user a
  15504. great deal of control over the exact shape of the bumpy features.
  15505. Each of the various pattern types available is in fact a
  15506. mathematical function that takes any x, y, z location and turns
  15507. it into a number between 0.0 and 1.0 inclusive. That number is
  15508. used to specify where the various high and low spots are.  The
  15509. slope_map lets you further shape the contours. It is best
  15510. illustrated with a gradient normal pattern. Suppose you have...
  15511.  
  15512.   plane{ z, 0
  15513.     pigment{ White }
  15514.     normal { gradient x }
  15515.   }
  15516. This gives a ramp wave pattern that looks like small linear ramps
  15517. that climb from the points at x=0 to x=1 and then abruptly drops
  15518. to 0 again to repeat the ramp from x=1 to x=2. A slope map turns
  15519. this simple linear ramp into almost any wave shape you want. The
  15520. syntax is as follows...
  15521.  
  15522. The syntax for slope_map is as follows:
  15523.  
  15524. SLOPE_MAP:
  15525.   slope_map{ SLOPE_MAP_BODY }
  15526. SLOPE_MAP_BODY:
  15527.   SLOPE_MAP_IDENTIFIER   |   SLOPE_MAP_ENTRY...
  15528. SLOPE_MAP_ENTRY:
  15529.   [ Value, <Height, Slope> ]
  15530. Note that the [] brackets are part of the actual SLOPE_MAP_ENTRY.
  15531. They are not notational symbols denoting optional parts. The
  15532. brackets surround each entry in the slope map. There may be from
  15533. 2 to 256 entries in the map.
  15534.  
  15535. Each Value is a float value between 0.0 and 1.0 inclusive and
  15536. each <Height, Slope> is a 2 component vectors such as <0,1> where
  15537. the first value represents the apparent height of the wave and
  15538. the second value represents the slope of the wave at that point.
  15539. The height should range between 0.0 and 1.0 but any value could
  15540. be used.
  15541.  
  15542. The slope value is the change in height per unit of distance. For
  15543. example a slope of zero means flat, a slope of 1.0 means slope
  15544. upwards at a 45 degree angle and a slope of -1 means slope down
  15545. at 45 degrees. Theoretically a slope straight up would have
  15546. infinite slope. In practice, slope values should be kept in the
  15547. range -3.0 to +3.0. Keep in mind that this is only the visually
  15548. apparent slope. A normal does not actually change the surface.
  15549.  
  15550. For example here is how to make the ramp slope up for the first
  15551. half and back down on the second half creating a triangle wave
  15552. with a sharp peak in the center.
  15553.  
  15554.   normal {
  15555.     gradient x       // this is the PATTERN_TYPE
  15556.     slope_map {
  15557.       [0   <0, 1>]   // start at bottom and slope up
  15558.       [0.5 <1, 1>]   // halfway through reach top still climbing
  15559.       [0.5 <1,-1>]   // abruptly slope down
  15560.       [1   <0,-1>]   // finish on down slope at bottom
  15561.     }
  15562.   }
  15563. The pattern function is evaluated and the result is a value from
  15564. 0.0 to 1.0. The first entry says that at x=0 the apparent height
  15565. is 0 and the slope is 1. At x=0.5 we are at height 1 and slope is
  15566. still up at 1. The third entry also specifies that at x=0.5
  15567. (actually at some tiny fraction above 0.5) we have height 1 but
  15568. slope -1 which is downwards. Finally at x=1 we are at height 0
  15569. again and still sloping down with slope -1.
  15570.  
  15571. Although this example connects the points using straight lines
  15572. the shape is actually a cubic spline. This example creates a
  15573. smooth sine wave.
  15574.  
  15575.   normal {
  15576.     gradient x          // this is the PATTERN_TYPE
  15577.     slope_map {
  15578.       [0    <0.5, 1>]   // start in middle and slope up
  15579.       [0.25 <1.0, 0>]   // flat slope at top of wave
  15580.       [0.5  <0.5,-1>]   // slope down at mid point
  15581.       [0.75 <0.0, 0>]   // flat slope at bottom
  15582.       [1    <0.5, 1>]   // finish in middle and slope up
  15583.     }
  15584.   }
  15585. This example starts at height 0.5 sloping up at slope 1. At a
  15586. fourth of the way through we are at the top of the curve at
  15587. height 1 with slope 0 which is flat. The space between these two
  15588. is a gentle curve because the start and end slopes are different.
  15589. At half way we are at half height sloping down to bottom out at
  15590. 3/4ths. By the end we are climbing at slope 1 again to complete
  15591. the cycle. There are more examples in slopemap.pov in the sample
  15592. scenes.
  15593.  
  15594. A slope_map may be used with any pattern except brick, checker,
  15595. hexagon, bumps, dents, ripples, waves, wrinkles and bump_map.
  15596.  
  15597. You may declare and use slope map identifiers. For example:
  15598.  
  15599.   #declare Fancy_Wave =
  15600.     slope_map {       // Now let's get fancy
  15601.       [0.0  <0, 1>]   // Do tiny triangle here
  15602.       [0.2  <1, 1>]   //  down
  15603.       [0.2  <1,-1>]   //     to
  15604.       [0.4  <0,-1>]   //       here.
  15605.       [0.4  <0, 0>]   // Flat area
  15606.       [0.5  <0, 0>]   //   through here.
  15607.       [0.5  <1, 0>]   // Square wave leading edge
  15608.       [0.6  <1, 0>]   //   trailing edge
  15609.       [0.6  <0, 0>]   // Flat again
  15610.       [0.7  <0, 0>]   //   through here.
  15611.       [0.7  <0, 3>]   // Start scallop
  15612.       [0.8  <1, 0>]   //   flat on top
  15613.       [0.9  <0,-3>]   //     finish here.
  15614.       [0.9  <0, 0>]   // Flat remaining through 1.0
  15615.     }
  15616.   object{ My_Object
  15617.     pigment { White }
  15618.     normal {
  15619.       wood
  15620.       slope_map { Fancy_Wave }
  15621.     }
  15622.   }
  15623.  
  15624. 4.7.2.2   Normal Maps and Normal Lists
  15625. Most of the time you will apply single normal pattern to an
  15626. entire surface but you may also create a pattern or blend of
  15627. normals using a normal_map. The syntax for a normal_map is
  15628. identical to a pigment_map except you specify a normal in each
  15629. map entry.
  15630.  
  15631. The syntax for normal_map is as follows:
  15632.  
  15633. NORMAL_MAP:
  15634.   normal_map{ NORMAL_MAP_BODY }
  15635. NORMAL_MAP_BODY:
  15636.   NORMAL_MAP_IDENTIFIER   |   NORMAL_MAP_ENTRY...
  15637. NORMAL_MAP_ENTRY:
  15638.   [ Value  NORMAL_BODY ]
  15639. Where Value is a float value between 0.0 and 1.0 inclusive and
  15640. each NORMAL_BODY is anything which can be inside a normal{...}
  15641. statement.  The normal keyword and {} braces need not be
  15642. specified.
  15643.  
  15644. Note that the [] brackets are part of the actual
  15645. NORMAL_MAP_ENTRY. They are not notational symbols denoting
  15646. optional parts. The brackets surround each entry in the normal
  15647. map. There may be from 2 to 256 entries in the map.
  15648.  
  15649. For example
  15650.  
  15651.   normal {
  15652.     gradient x       //this is the PATTERN_TYPE
  15653.     normal_map {
  15654.       [0.3  bumps scale 2]
  15655.       [0.3  dents]
  15656.       [0.6  dents]
  15657.       [0.9  marble turbulence 1]
  15658.     }
  15659.   }
  15660. When the gradient x function returns values from 0.0 to 0.3 then
  15661. the scaled bumps normal is used. From 0.3 to 0.6 dents are From
  15662. 0.6 up to 0.9 a blend of dents and a turbulent marble is used.
  15663. From 0.9 on up only the turbulent marble is used.
  15664.  
  15665. Normal maps may be nested to any level of complexity you desire.
  15666. The normals in a map may have slope maps or normal maps or any
  15667. type of normal you want.
  15668.  
  15669. A normal map is also used with the average normal type. See
  15670. "Average" for details.
  15671.  
  15672. Entire normals in a normal list may also be used with the block
  15673. patterns such as checker, hexagon and brick. For example...
  15674.  
  15675.   normal {
  15676.     checker
  15677.       normal { gradient x scale .2 }
  15678.       normal { gradient y scale .2 }
  15679.     }
  15680.   }
  15681. Note that in the case of block patterns the normal wrapping is
  15682. required around the normal information.
  15683.  
  15684. You may not use normal_map or individual normals with a bump_map.
  15685. See section "Texture Maps" for an alternative way to do this.
  15686.  
  15687. You may declare and use normal map identifiers but the only way
  15688. to declare a normal block pattern list is to declare a normal
  15689. identifier for the entire normal.
  15690.  
  15691.  
  15692. 4.7.2.3   Bump Maps
  15693. When all else fails and none of the above normal pattern types
  15694. meets your needs you can use a bump_map to wrap a 2-D bit-mapped
  15695. bump pattern around your 3-D objects.
  15696.  
  15697. Instead of placing the color of the image on the shape like an
  15698. image_map a bump_map perturbs the surface normal based on the
  15699. color of the image at that point. The result looks like the image
  15700. has been embossed into the surface. By default, a bump map uses
  15701. the brightness of the actual color of the pixel. Colors are
  15702. converted to gray scale internally before calculating height.
  15703. Black is a low spot, white is a high spot. The image's index
  15704. values may be used instead (see section "Use_Index and Use_Color"
  15705. below).
  15706.  
  15707.  
  15708. 4.7.2.3.1 Specifying a Bump Map
  15709. The syntax for an bump_map is:
  15710.  
  15711. BUMP_MAP:
  15712.   normal{
  15713.      bump_map{ BITMAP_TYPE "bitmap.ext" [BUMP_MAP_MODS...] }
  15714.      [NORMAL_MODFIERS...]
  15715.   }
  15716. BITMAP_TYPE:
  15717.   gif   |   tga   |   iff   |   ppm   |   pgm   |   png   |
  15718.   sys
  15719. BUMP_MAP_MOD:
  15720.   map_type  Type   |   once   |   interpolate  Type   |
  15721.   use_color   |   use_colour   |   bump_size  Value
  15722. After the required BITMAP_TYPE keyword is a string expression
  15723. containing the name of a bitmapped bump file of the specified
  15724. type.  Several optional modifiers may follow the file
  15725. specification. The modifiers are described below. Note that
  15726. earlier versions of POV-Ray allowed some modifiers before the
  15727. BITMAP_TYPE but that syntax is being phased out in favor of the
  15728. syntax described here.  Note sys format is a system-specific
  15729. format such as BMP for Windows or Pict for Macintosh.
  15730.  
  15731. Filenames specified in the bump_map statements will be searched
  15732. for in the home (current) directory first and, if not found, will
  15733. then be searched for in directories specified by any +L or
  15734. Library_Path options active. This would facilitate keeping all
  15735. your bump maps files in a separate subdirectory and giving a
  15736. Library_Path option to specify where your library of bump maps
  15737. are.  See "Library Paths" for details.
  15738.  
  15739. By default, the bump pattern is mapped onto the x-y-plane. The
  15740. bump pattern is projected onto the object as though there were a
  15741. slide projector somewhere in the -z-direction. The pattern
  15742. exactly fills the square area from (x,y) coordinates (0,0) to
  15743. (1,1) regardless of the pattern's original size in pixels. If you
  15744. would like to change this default you may translate, rotate or
  15745. scale the pigment or texture to map it onto the object's surface
  15746. as desired.  If you would like to change this default orientation
  15747. you may translate, rotate or scale the pigment or texture to map
  15748. it onto the object's surface as desired.
  15749.  
  15750. The file name is optionally followed by one or more
  15751. BITMAP_MODIFIERS. The bump_size, use_color and use_index
  15752. modifiers are specific to bump maps and are discussed in the
  15753. following sections. See section "Bitmap Modifiers" for the
  15754. generic bitmap modifiers map_type, once and interpolate described
  15755. in "Bitmap Modifiers"
  15756.  
  15757.  
  15758. 4.7.2.3.2 Bump_Size
  15759. The relative bump size can be scaled using the bump_size
  15760. modifier.  The bump size number can be any number other than 0
  15761. but typical values are from about 0.1 to as high as 4.0 or 5.0.
  15762.  
  15763.   normal {
  15764.     bump_map {
  15765.       gif "stuff.gif"
  15766.       bump_size 5.0
  15767.     }
  15768.   }
  15769. Originally bump_size could only be used inside a bump map but it
  15770. can now be used with any normal. Typically it is used to override
  15771. a previously defined size. For example:
  15772.  
  15773.   normal {
  15774.     My_Normal   //this is a previously defined normal identifier
  15775.     bump_size 2.0
  15776.   }
  15777.  
  15778. 4.7.2.3.3 Use_Index and Use_Color
  15779. Usually the bump map converts the color of the pixel in the map
  15780. to a gray scale intensity value in the range 0.0 to 1.0 and
  15781. calculates the bumps based on that value. If you specify
  15782. use_index, the bump map uses the color's palette number to
  15783. compute as the height of the bump at that point. So, color number
  15784. 0 would be low and color number 255 would be high (if the image
  15785. has 256 palette entries). The actual color of the pixels doesn't
  15786. matter when using the index. This option is only available on
  15787. palette based formats. The use_color keyword may be specified to
  15788. explicitly note that the color methods should be used instead.
  15789. The alternate spelling use_colour is also valid. These modifiers
  15790. may only be used inside the bump_map statement.
  15791.  
  15792.  
  15793. 4.7.3     Finish
  15794. The finish properties of a surface can greatly affect its
  15795. appearance. How does light reflect? What happens in shadows? What
  15796. kind of highlights are visible. To answer these questions you
  15797. need a finish.
  15798.  
  15799. The syntax for finish is as follows:
  15800.  
  15801. FINISH:
  15802.   finish { [FINISH_IDENTIFIER] [FINISH_ITEMS...] }
  15803. FINISH_ITEMS:
  15804.   ambient COLOR   |   diffuse Amount   |   brilliance Amount   |
  15805.   phong Amount   |   phong_size Amount   |
  15806.   specular Amount   |   roughness Amount   |
  15807.   metallic [Amount]   |   reflection COLOR   |
  15808.   reflection_exponent Amount   |
  15809.   irid { Irid_Amount [IRID_ITEMS...] }   |   crand Amount
  15810. IRID_ITEMS:
  15811.   thickness Amount   |   turbulence Amount
  15812. The FINISH_IDENTIFIER is optional but should proceed all other
  15813. items. Any items after the FINISH_IDENTIFIER modify or override
  15814. settings given in the FINISH_IDENTIFIER. If no identifier is
  15815. specified then the items modify the finish values in the current
  15816. default texture.  Note that transformations are not allowed
  15817. inside a finish because finish items cover the entire surface
  15818. uniformly.  Each of the FINISH_ITEMS listed above is described in
  15819. sub-sections below.
  15820.  
  15821. In earlier versions of POV-Ray, the refraction, ior, and caustics
  15822. keywords were part of the finish statement but they are now part
  15823. of the interior statement.  They are still supported under finish
  15824. for backward compatibility but the results may not be 100%
  15825. identical to previous versions. See "Why are Interior and Media
  15826. Necessary?" for details.
  15827.  
  15828. A finish statement is part of a texture specification.  However
  15829. it can be tedious to use a texture statement just to add a
  15830. highlights or other lighting properties to an object. Therefore
  15831. you may attach a finish directly to an object without explicitly
  15832. specifying that it as part of a texture. For example instead of
  15833. this:
  15834.  
  15835.   object {My_Object texture{finish{phong 0.5}}}
  15836. you may shorten it to:
  15837.  
  15838.   object {My_Object finish{phong 0.5}}
  15839. Note however that doing so creates an entire texture structure
  15840. with default pigment and normal statements just as if you had
  15841. explicitly typed the full texture{...} around it.
  15842.  
  15843. Finish identifiers may be declared to make scene files more
  15844. readable and to parameterize scenes so that changing a single
  15845. declaration changes many values. An identifier is declared as
  15846. follows.
  15847.  
  15848. FINISH_DECLARATION:
  15849.   #declare IDENTIFIER = FINISH   |
  15850.   #local IDENTIFIER = FINISH
  15851. Where IDENTIFIER is the name of the identifier up to 40
  15852. characters long and FINISH is any valid finish statement.  See
  15853. "#declare vs. #local" for information on identifier scope.
  15854.  
  15855.  
  15856. 4.7.3.1   Ambient
  15857. The light you see in dark shadowed areas comes from diffuse
  15858. reflection off of other objects. This light cannot be directly
  15859. modeled using ray-tracing. However we can use a trick called
  15860. ambient lighting to simulate the light inside a shadowed area.
  15861.  
  15862. Ambient light is light that is scattered everywhere in the room.
  15863. It bounces all over the place and manages to light objects up a
  15864. bit even where no light is directly shining. Computing real
  15865. ambient light would take far too much time, so we simulate
  15866. ambient light by adding a small amount of white light to each
  15867. texture whether or not a light is actually shining on that
  15868. texture.
  15869.  
  15870. This means that the portions of a shape that are completely in
  15871. shadow will still have a little bit of their surface color. It's
  15872. almost as if the texture glows, though the ambient light in a
  15873. texture only affects the shape it is used on.
  15874.  
  15875. The ambient keyword controls the amount of ambient light. Usually
  15876. a single float value is specified even though the syntax calls
  15877. for a color. For example a float value of 0.3 gets promoted to
  15878. the full color vector <0.3,0.3,0.3,0.3,0.3> which is acceptable
  15879. because only the red, green and blue parts are used.
  15880.  
  15881. The default value is 0.1 which gives very little ambient light.
  15882. The value can range from 0.0 to 1.0. Ambient light affects both
  15883. shadowed and non-shadowed areas so if you turn up the ambient
  15884. value you may want to turn down the diffuse and reflection
  15885. values.
  15886.  
  15887. Note that this method doesn't account for the color of
  15888. surrounding objects. If you walk into a room that has red walls,
  15889. floor and ceiling then your white clothing will look pink from
  15890. the reflected light. POV-Ray's ambient shortcut doesn't account
  15891. for this. There is also no way to model specular reflected
  15892. indirect illumination such as the flashlight shining in a mirror.
  15893.  
  15894. You may color the ambient light using one of two methods. You may
  15895. specify a color rather than a float after the ambient keyword in
  15896. each finish statement. For example
  15897.  
  15898.    finish { ambient rgb <0.3,0.1,0.1> } //a pink ambient
  15899. You may also specify the overall ambient light source used when
  15900. calculating the ambient lighting of an object using the global
  15901. ambient_light setting. The formula is given by
  15902.  
  15903.    Ambient = Finish_Ambient * Global_Ambient_Light_Source
  15904.  
  15905. See section "Ambient Light" for details.
  15906.  
  15907.  
  15908. 4.7.3.2   Diffuse Reflection Items
  15909. When light reflects off of a surface the laws of physics say that
  15910. it should leave the surface at the exact same angle it came in.
  15911. This is similar to the way a billiard ball bounces off a bumper
  15912. of a pool table. This perfect reflection is called specular
  15913. reflection. However only very smooth polished surfaces reflect
  15914. light in this way. Most of the time, light reflects and is
  15915. scattered in all directions by the roughness of the surface. This
  15916. scattering is called diffuse reflection because the light
  15917. diffuses or spreads in a variety of directions. It accounts for
  15918. the majority of the reflected light we see.
  15919.  
  15920. POV-Ray and most other ray-tracers can only simulate directly
  15921. light which comes directly from actual light sources.  Light
  15922. coming from other objects such as mirrors via specular reflection
  15923. (such as shining a flashlight onto a mirror for example) cannot
  15924. be simulated.  Neither can we simulate light coming from other
  15925. objects via diffuse reflections.  For example look at some dark
  15926. area under a desk or in a corner: even though a lamp may not
  15927. directly illuminate that spot, you can still see a little bit
  15928. because light comes from diffuse reflection off of nearby
  15929. objects.
  15930.  
  15931.  
  15932. 4.7.3.2.1 Diffuse
  15933. The keyword diffuse is used in a finish statement to control how
  15934. much of the light coming directly from any light sources is
  15935. reflected via diffuse reflection. For example
  15936.  
  15937.   finish {diffuse 0.7}
  15938. means that 70% of the light seen comes from direct illumination
  15939. from light sources. The default value is diffuse 0.6.
  15940.  
  15941.  
  15942. 4.7.3.2.2 Brilliance
  15943. The amount of direct light that diffuses from an object depends
  15944. upon the angle at which it hits the surface. When light hits at a
  15945. shallow angle it illuminates less. When it is directly above a
  15946. surface it illuminates more. The brilliance keyword can be used
  15947. in a finish statement to vary the way light falls off depending
  15948. upon the angle of incidence.  This controls the tightness of the
  15949. basic diffuse illumination on objects and slightly adjusts the
  15950. appearance of surface shininess.  Objects may appear more
  15951. metallic by increasing their brilliance. The default value is
  15952. 1.0.  Higher values from 5.0 to about 10.0 cause the light to
  15953. fall off less at medium to low angles. There are no limits to the
  15954. brilliance value.  Experiment to see what works best for a
  15955. particular situation. This is best used in concert with
  15956. highlighting.
  15957.  
  15958.  
  15959. 4.7.3.2.3 Crand Graininess
  15960. Very rough surfaces, such as concrete or sand, exhibit a dark
  15961. graininess in their apparent color. This is caused by the shadows
  15962. of the pits or holes in the surface. The crand keyword can be
  15963. added to a finish cause a minor random darkening in the diffuse
  15964. reflection of direct illumination. Typical values range from
  15965. crand 0.01 to crand 0.5 or higher. The default value is 0. For
  15966. example:
  15967.  
  15968.   finish { crand 0.05 }
  15969. This feature is carried over from the earliest versions of POV-
  15970. Ray and is considered obsolete. This is because the grain or
  15971. noise introduced by this feature is applied on a pixel-by-pixel
  15972. basis. This means that it will look the same on far away objects
  15973. as on close objects. The effect also looks different depending
  15974. upon the resolution you are using for the rendering. Note that
  15975. this should not be used when rendering animations. This is the
  15976. one of a few truly random features in POV-Ray and will produce an
  15977. annoying flicker of flying pixels on any textures animated with a
  15978. crand value.  For these reasons it is not a very accurate way to
  15979. model the rough surface effect.
  15980.  
  15981.  
  15982. 4.7.3.3   Highlights
  15983. Highlights are the bright spots that appear when a light source
  15984. reflects off of a smooth object. They are a blend of specular
  15985. reflection and diffuse reflection. They are specular-like because
  15986. they depend upon viewing angle and illumination angle. However
  15987. they are diffuse-like because some scattering occurs. In order to
  15988. exactly model a highlight you would have to calculate specular
  15989. reflection off of thousands of microscopic bumps called micro
  15990. facets. The more that micro facets are facing the viewer the
  15991. shinier the object appears and the tighter the highlights become.
  15992. POV-Ray uses two different models to simulate highlights without
  15993. calculating micro facets. They are the specular and Phong models.
  15994.  
  15995. Note that specular and Phong highlights are not mutually
  15996. exclusive. It is possible to specify both and they will both take
  15997. effect. Normally, however, you will only specify one or the
  15998. other.
  15999.  
  16000.  
  16001. 4.7.3.3.1 Phong Highlights
  16002. The phong keyword in the finish statement controls the amount of
  16003. Phong highlighting on the object. It causes bright shiny spots on
  16004. the object that are the color of the light source being
  16005. reflected.
  16006.  
  16007. The Phong method measures the average of the facets facing in the
  16008. mirror direction from the light sources to the viewer.
  16009.  
  16010. Phong's value is typically from 0.0 to 1.0, where 1.0 causes
  16011. complete saturation to the light source's color at the brightest
  16012. area (center) of the highlight. The default phong 0.0 gives no
  16013. highlight.
  16014.  
  16015. The size of the highlight spot is defined by the phong_size
  16016. value. The larger the phong size the tighter, or smaller, the
  16017. highlight and the shinier the appearance.  The smaller the phong
  16018. size the looser, or larger, the highlight and the less glossy the
  16019. appearance.
  16020.  
  16021. Typical values range from 1.0 (very dull) to 250 (highly
  16022. polished) though any values may be used. Default phong size is 40
  16023. (plastic) if phong_size is not specified. For example:
  16024.  
  16025.   finish { phong 0.9 phong_size 60 }
  16026. If phong is not specified phong_size has no effect.
  16027.  
  16028.  
  16029. 4.7.3.3.2 Specular Highlight
  16030. The specular keyword in a finish statement produces a highlight
  16031. which is very similar to Phong highlighting but it uses slightly
  16032. different model. The specular model more closely resembles real
  16033. specular reflection and provides a more credible spreading of the
  16034. highlights occurring near the object horizons.
  16035.  
  16036. The specular value is typically from 0.0 to 1.0, where 1.0 causes
  16037. complete saturation to the light source's color at the brightest
  16038. area (center) of the highlight. The default specular 0.0 gives no
  16039. highlight.
  16040.  
  16041. The size of the spot is defined by the value given the roughness
  16042. keyword. Typical values range from 1.0 (very rough - large
  16043. highlight) to 0.0005 (very smooth - small highlight). The default
  16044. value, if roughness is not specified, is 0.05 (plastic).
  16045.  
  16046. It is possible to specify wrong values for roughness that will
  16047. generate an error when you try to render the file. Don't use 0
  16048. and if you get errors check to see if you are using a very, very
  16049. small roughness value that may be causing the error. For example:
  16050.  
  16051.   finish {specular 0.9  roughness 0.02}
  16052. If specular is not specified roughness has no effect.
  16053.  
  16054. Note that when light reflects perfectly of a smooth surface such
  16055. as a mirror, it is called specular reflection however such
  16056. reflection is not controlled by the specular keyword. The
  16057. reflection keyword controls mirror-like specular reflection.
  16058.  
  16059.  
  16060. 4.7.3.3.3 Metallic Highlight Modifier
  16061. The keyword metallic may be used with Phong or specular
  16062. highlights. This keyword indicates that the color of the
  16063. highlights will be calculated by an empirical function that
  16064. models the reflectivity of metallic surfaces.
  16065.  
  16066. Normally highlights are the color of the light source.  Adding
  16067. this keyword filters the highlight so that white light reflected
  16068. from a metallic surface takes the color of the surface.
  16069.  
  16070. The metallic keyword may optionally be follow by a numeric value
  16071. to specify the influence the amount of the effect.  If no keyword
  16072. is specified, the default value is zero.  If the keyword is
  16073. specified without a value, the default value is one. For example:
  16074.  
  16075.   finish {
  16076.     phong 0.9
  16077.     phong_size 60
  16078.     metallic
  16079.   }
  16080. If phong or specular keywords are not specified then metallic has
  16081. no effect.
  16082.  
  16083.  
  16084. 4.7.3.4   Specular Reflection
  16085. When light does not diffuse and it does reflect at the same angle
  16086. as it hits an object, it is called specular reflection. Such
  16087. mirror-like reflection is controlled by the reflection keyword in
  16088. a finish statement. For example:
  16089.  
  16090.   finish { reflection 1.0 ambient 0 diffuse 0 }
  16091. This gives the object a mirrored finish. It will reflect all
  16092. other elements in the scene. Usually a single float value is
  16093. specified after the keyword even though the syntax calls for a
  16094. color. For example a float value of 0.3 gets promoted to the full
  16095. color vector < 0.3,0.3,0.3,0.3,0.3> which is acceptable because
  16096. only the red, green and blue parts are used.
  16097.  
  16098. The value can range from 0.0 to 1.0. By default there is no
  16099. reflection.
  16100.  
  16101. Adding reflection to a texture makes it take longer to render
  16102. because an additional ray must be traced. The reflected light may
  16103. be tinted by specifying a color rather than a float. For example
  16104.  
  16105.    finish { reflection rgb <1,0,0> }
  16106. gives a red mirror that only reflects red light.
  16107.  
  16108. POV-Ray uses a limited light model that cannot distinguish
  16109. between objects which are simply brightly colored and objects
  16110. which are extremely bright.  A white piece of paper, a light
  16111. bulb, the sun, and a supernova, all would be modeled as
  16112. rgb<1,1,1> and slightly off-white objects would be only slightly
  16113. darker.  It is especially difficult to model partially reflective
  16114. surfaces in a realistic way.  Middle and lower brightness objects
  16115. typically look too bright when reflected.  If you reduce the
  16116. reflection value, it tends to darken the bright objects too much.
  16117. Therefore the reflection_exponent keyword has been added.  It
  16118. produces non-linear reflection intensities.  The default value of
  16119. 1.0 produces a linear curve.  Lower values darken middle and low
  16120. intensities and keeps high intensity reflections bright.  This is
  16121. a somewhat experimental feature designed for artistic use.  It
  16122. does not directly correspond to any real world reflective
  16123. properties.  We are researching ways to deal with this issue in a
  16124. more scientific model.  The reflection_exponent has no effect
  16125. unless reflection is used.
  16126.  
  16127. Note that although such reflection is called specular it is not
  16128. controlled by the specular keyword. That keyword controls a
  16129. specular highlight.
  16130.  
  16131.  
  16132. 4.7.3.5   Iridescence
  16133. Iridescence, or Newton's thin film interference, simulates the
  16134. effect of light on surfaces with a microscopic transparent film
  16135. overlay. The effect is like an oil slick on a puddle of water or
  16136. the rainbow hues of a soap bubble.  This effect is controlled by
  16137. the irid statement specified inside a finish statement.
  16138.  
  16139. This parameter modifies the surface color as a function of the
  16140. angle between the light source and the surface. Since the effect
  16141. works in conjunction with the position and angle of the light
  16142. sources to the surface it does not behave in the same ways as a
  16143. procedural pigment pattern.
  16144.  
  16145. The syntax is:
  16146.  
  16147. IRID:
  16148.   irid { Irid_Amount [IRID_ITEMS...] }
  16149. IRID_ITEMS:
  16150.   thickness Amount   |   turbulence Amount
  16151. The required Irid_Amount parameter is the contribution of the
  16152. iridescence effect to the overall surface color. As a rule of
  16153. thumb keep to around 0.25 (25% contribution) or less, but
  16154. experiment. If the surface is coming out too white, try lowering
  16155. the diffuse and possibly the ambient values of the surface.
  16156.  
  16157. The thickness keyword represents the film's thickness. This is an
  16158. awkward parameter to set, since the thickness value has no
  16159. relationship to the object's scale.  Changing it affects the
  16160. scale or busy-ness of the effect. A very thin film will have a
  16161. high frequency of color changes while a thick film will have
  16162. large areas of color.  The default value is zero.
  16163.  
  16164. The thickness of the film can be varied with the turbulence
  16165. keyword. You can only specify the amount of turbulence with
  16166. iridescence.  The octaves, lambda, and omega values are
  16167. internally set and are not adjustable by the user at this time.
  16168. This parameter varies only a single value: the thickness.
  16169. Therefore the value must be a single float value.  It cannot be a
  16170. vector as in other uses of the turbulence keyword.
  16171.  
  16172. In addition, perturbing the object's surface normal through the
  16173. use of bump patterns will affect iridescence.
  16174.  
  16175. For the curious, thin film interference occurs because, when the
  16176. ray hits the surface of the film, part of the light is reflected
  16177. from that surface, while a portion is transmitted into the film.
  16178. This subsurface ray travels through the film and eventually
  16179. reflects off the opaque substrate. The light emerges from the
  16180. film slightly out of phase with the ray that was reflected from
  16181. the surface.
  16182.  
  16183. This phase shift creates interference, which varies with the
  16184. wavelength of the component colors, resulting in some wavelengths
  16185. being reinforced, while others are cancelled out. When these
  16186. components are recombined, the result is iridescence.  See also
  16187. the global setting "Irid_Wavelength".
  16188.  
  16189. The concept used for this feature came from the book Fundamentals
  16190. of Three-Dimensional Computer Graphics by Alan Watt (Addison-
  16191. Wesley).
  16192.  
  16193.  
  16194. 4.7.4     Halo
  16195. Earlier versions of POV-Ray used a feature called halo to
  16196. simulate fine particles such as smoke, steam, fog, or flames.
  16197. The halo statement was part of the texture statement.  This
  16198. feature has been discontinued and replaced by the interior and
  16199. media statements which are object modifiers outside the texture
  16200. statement.
  16201.  
  16202. See "Why are Interior and Media Necessary?" for a detailed
  16203. explanation on the reasons for the change.  See "Media" for
  16204. details on media.
  16205.  
  16206.  
  16207. 4.7.5     Patterned Textures
  16208. Patterned textures are complex textures made up of multiple
  16209. textures.  The component textures may be plain textures or may be
  16210. made up of patterned textures. A plain texture has just one
  16211. pigment, normal and finish statement. Even a pigment with a
  16212. pigment map is still one pigment and thus considered a plain
  16213. texture as are normals with normal map statements.
  16214.  
  16215. Patterned textures use either a texture_map statement to specify
  16216. a blend or pattern of textures or they use block textures such as
  16217. checker with a texture list or a bitmap similar to an image map
  16218. called a material map specified with a material_map statement.
  16219.  
  16220. The syntax is...
  16221.  
  16222. PATTERNED_TEXTURE:
  16223.   texture { [PATTERNED_TEXTURE_ID] [TRANSFORMATIONS...] }   |
  16224.   texture { PATTERN_TYPE [TEXTURE_PATTERN_MODIFIERS...] }   |
  16225.   texture { tiles TEXTURE  tile2 TEXTURE [TRANSFORMATIONS...] }
  16226.   |
  16227.   texture {
  16228.      material_map{
  16229.        BITMAP_TYPE "bitmap.ext" [BITMAP_MODS...] TEXTURE...
  16230.      [TRANSFORMATIONS...]
  16231.      }
  16232.   }
  16233. TEXTURE_PATTERN_MODIFIER:
  16234.   PATTERN_MODIFIER   |   TEXTURE_LIST   |
  16235.   texture_map{ TEXTURE_MAP_BODY }
  16236. There are restrictions on using patterned textures. A patterned
  16237. texture may not be used as a default texture (see section "The
  16238. #default Directive"). A patterned texture cannot be used as a
  16239. layer in a layered texture however you may use layered textures
  16240. as any of the textures contained within a patterned texture.
  16241.  
  16242.  
  16243. 4.7.5.1   Texture Maps
  16244. In addition to specifying blended color with a color map or a
  16245. pigment map you may create a blend of textures using texture_map.
  16246. The syntax for a texture map is identical to the pigment map
  16247. except you specify a texture in each map entry.
  16248.  
  16249. The syntax for texture_map is as follows:
  16250.  
  16251. TEXTURE_MAP:
  16252.   texture_map{ TEXTURE_MAP_BODY }
  16253. TEXTURE_MAP_BODY:
  16254.   TEXTURE_MAP_IDENTIFIER   |   TEXTURE_MAP_ENTRY...
  16255. TEXTURE_MAP_ENTRY:
  16256.   [ Value  TEXTURE_BODY ]
  16257. Where Value is a float value between 0.0 and 1.0 inclusive and
  16258. each TEXTURE_BODY is anything which can be inside a texture{...}
  16259. statement.  The texture keyword and {} braces need not be
  16260. specified.
  16261.  
  16262. Note that the [] brackets are part of the actual
  16263. TEXTURE_MAP_ENTRY. They are not notational symbols denoting
  16264. optional parts. The brackets surround each entry in the texture
  16265. map. There may be from 2 to 256 entries in the map.
  16266.  
  16267. For example:
  16268.  
  16269.   texture {
  16270.     gradient x       //this is the PATTERN_TYPE
  16271.     texture_map {
  16272.       [0.3  pigment{Red} finish{phong 1}]
  16273.       [0.3  T_Wood11]    //this is a texture identifier
  16274.       [0.6  T_Wood11]
  16275.       [0.9  pigment{DMFWood4} finish{Shiny}]
  16276.     }
  16277.   }
  16278. When the gradient x function returns values from 0.0 to 0.3 the
  16279. red highlighted texture is used. From 0.3 to 0.6 the texture
  16280. identifier T_Wood11 is used. From 0.6 up to 0.9 a blend of
  16281. T_Wood11 and a shiny DMFWood4 is used. From 0.9 on up only the
  16282. shiny wood is used.
  16283.  
  16284. Texture maps may be nested to any level of complexity you desire.
  16285. The textures in a map may have color maps or texture maps or any
  16286. type of texture you want.
  16287.  
  16288. The blended area of a texture map works by fully calculating both
  16289. contributing textures in their entirety and then linearly
  16290. interpolating the apparent colors. This means that reflection,
  16291. refraction and lighting calculations are done twice for every
  16292. point.  This is in contrast to using a pigment map and a normal
  16293. map in a plain texture, where the pigment is computed, then the
  16294. normal, then reflection, refraction and lighting are calculated
  16295. once for that point.
  16296.  
  16297. Entire textures may also be used with the block patterns such as
  16298. checker, hexagon and brick. For example...
  16299.  
  16300.   texture {
  16301.     checker
  16302.       texture { T_Wood12 scale .8 }
  16303.       texture {
  16304.         pigment { White_Marble }
  16305.         finish { Shiny }
  16306.         scale .5
  16307.       }
  16308.     }
  16309.   }
  16310. Note that in the case of block patterns the texture wrapping is
  16311. required around the texture information. Also note that this
  16312. syntax prohibits the use of a layered texture however you can
  16313. work around this by declaring a texture identifier for the
  16314. layered texture and referencing the identifier.
  16315.  
  16316. A texture map is also used with the average texture type. See
  16317. "Average" for details.
  16318.  
  16319. You may declare and use texture map identifiers but the only way
  16320. to declare a texture block pattern list is to declare a texture
  16321. identifier for the entire texture.
  16322.  
  16323.  
  16324. 4.7.5.2   Tiles
  16325. Earlier versions of POV-Ray had a patterned texture called a
  16326. tiles texture.  It used the tiles and tile2 keywords to create a
  16327. checkered pattern of textures.
  16328.  
  16329. TILES_TEXTURE:
  16330.   texture { tiles TEXTURE  tile2 TEXTURE [TRANSFORMATIONS...] }
  16331. Although it is still supported for backwards compatibility you
  16332. should use a checker block texture pattern described in section
  16333. "Texture Maps" rather than tiles textures.
  16334.  
  16335.  
  16336. 4.7.5.3   Material Maps
  16337. The material_map patterned texture extends the concept of image
  16338. maps to apply to entire textures rather than solid colors. A
  16339. material map allows you to wrap a 2-D bit-mapped texture pattern
  16340. around your 3-D objects.
  16341.  
  16342. Instead of placing a solid color of the image on the shape like
  16343. an image map, an entire texture is specified based on the index
  16344. or color of the image at that point. You must specify a list of
  16345. textures to be used like a texture palette rather than the usual
  16346. color palette.
  16347.  
  16348. When used with mapped file types such as GIF, and some PNG and
  16349. TGA images, the index of the pixel is used as an index into the
  16350. list of textures you supply. For unmapped file types such as some
  16351. PNG and TGA images the 8 bit value of the red component in the
  16352. range 0-255 is used as an index.
  16353.  
  16354. If the index of a pixel is greater than the number of textures in
  16355. your list then the index is taken modulo N where N is the length
  16356. of your list of textures.
  16357.  
  16358. Note: The material_map statement has nothing to do with the
  16359. material statement.  A material_map is not a way to create
  16360. patterned material.  See "Material" for explanation of this
  16361. unrelated, yet similarly named, older feature.
  16362.  
  16363.  
  16364. 4.7.5.3.1 Specifying a Material Map
  16365. The syntax for an material_map is:
  16366.  
  16367. MATERIAL_MAP:
  16368.   texture {
  16369.      material_map{
  16370.        BITMAP_TYPE "bitmap.ext" [BITMAP_MODS...] TEXTURE...
  16371.      [TRANSFORMATIONS...]
  16372.      }
  16373.   }
  16374. BITMAP_TYPE:
  16375.   gif   |   tga   |   iff   |   ppm   |   pgm   |   png   |
  16376.   sys
  16377. BITMAP_MOD:
  16378.   map_type  Type   |   once   |   interpolate  Type
  16379. After the required BITMAP_TYPE keyword is a string expression
  16380. containing the name of a bitmapped material file of the specified
  16381. type.  Several optional modifiers may follow the file
  16382. specification. The modifiers are described below. Note that
  16383. earlier versions of POV-Ray allowed some modifiers before the
  16384. BITMAP_TYPE but that syntax is being phased out in favor of the
  16385. syntax described here.  Note sys format is a system-specific
  16386. format such as BMP for Windows or Pict for Macintosh.
  16387.  
  16388. Filenames specified in the material_map statements will be
  16389. searched for in the home (current) directory first and, if not
  16390. found, will then be searched for in directories specified by any
  16391. +L or Library_Path options active. This would facilitate keeping
  16392. all your material maps files in a separate subdirectory and
  16393. giving a Library_Path option to specify where your library of
  16394. material maps are.  See "Library Paths" for details.
  16395.  
  16396. By default, the material is mapped onto the x-y-plane. The
  16397. material is projected onto the object as though there were a
  16398. slide projector somewhere in the -z-direction. The material
  16399. exactly fills the square area from (x,y) coordinates (0,0) to
  16400. (1,1) regardless of the material's original size in pixels. If
  16401. you would like to change this default you may translate, rotate
  16402. or scale the texture or texture to map it onto the object's
  16403. surface as desired.
  16404.  
  16405. The file name is optionally followed by one or more
  16406. BITMAP_MODIFIERS.  There are no modifiers which are unique to a
  16407. material_map.  It only uses the generic bitmap modifiers
  16408. map_type, once and interpolate described in "Bitmap Modifiers".
  16409.  
  16410. Although interpolate is legal in material maps, the color index
  16411. is interpolated before the texture is chosen. It does not
  16412. interpolate the final color as you might hope it would. In
  16413. general, interpolation of material maps serves no useful purpose
  16414. but this may be fixed in future versions.
  16415.  
  16416. Next is one or more texture statements.  Each texture in the list
  16417. corresponds to an index in the bitmap file.  For example:
  16418.  
  16419.    texture {
  16420.       material_map {
  16421.          png "povmap.png"
  16422.          texture {  //used with index 0
  16423.             pigment {color red 0.3 green 0.1 blue 1}
  16424.             normal  {ripples 0.85 frequency 10 }
  16425.             finish  {specular 0.75}
  16426.             scale 5
  16427.          }
  16428.          texture {  //used with index 1
  16429.             pigment {White}
  16430.             finish {ambient 0 diffuse 0 reflection 0.9 specular
  16431. 0.75}
  16432.          }
  16433.          // used with index 2
  16434.          texture {pigment{NeonPink} finish{Luminous}}
  16435.          texture {  //used with index 3
  16436.             pigment {
  16437.                gradient y
  16438.                color_map {
  16439.                   [0.00 rgb < 1 , 0 , 0>]
  16440.                   [0.33 rgb < 0 , 0 , 1>]
  16441.                   [0.66 rgb < 0 , 1 , 0>]
  16442.                   [1.00 rgb < 1 , 0 , 0>]
  16443.                }
  16444.             }
  16445.             finish{specular 0.75}
  16446.             scale 8
  16447.          }
  16448.       }
  16449.       scale 30
  16450.       translate <-15, -15, 0>
  16451.    }
  16452. After a material_map statement but still inside the texture
  16453. statement you may apply any legal texture modifiers. Note that no
  16454. other pigment, normal, or finish statements may be added to the
  16455. texture outside the material map. The following is illegal:
  16456.  
  16457.   texture {
  16458.     material_map {
  16459.       gif "matmap.gif"
  16460.       texture {T1}
  16461.       texture {T2}
  16462.       texture {T3}
  16463.     }
  16464.     finish {phong 1.0}
  16465.   }
  16466. The finish must be individually added to each texture.  Note that
  16467. earlier versions of POV-Ray allowed such specifications but they
  16468. were ignored. The above restrictions on syntax were necessary for
  16469. various bug fixes. This means some POV-Ray 1.0 scenes using
  16470. material maps many need minor modifications that cannot be done
  16471. automatically with the version compatibility mode.
  16472.  
  16473. If particular index values are not used in an image then it may
  16474. be necessary to supply dummy textures. It may be necessary to use
  16475. a paint program or other utility to examine the map file's
  16476. palette to determine how to arrange the texture list.
  16477.  
  16478. The textures within a material map texture may be layered but
  16479. material map textures do not work as part of a layered texture.
  16480. To use a layered texture inside a material map you must declare
  16481. it as a texture identifier and invoke it in the texture list.
  16482.  
  16483.  
  16484. 4.7.6     Layered Textures
  16485. It is possible to create a variety of special effects using
  16486. layered textures. A layered texture consists of several textures
  16487. that are partially transparent and are laid one on top of the
  16488. other to create a more complex texture. The different texture
  16489. layers show through the transparent portions to create the
  16490. appearance of one texture that is a combination of several
  16491. textures.
  16492.  
  16493. You create layered textures by listing two or more textures one
  16494. right after the other. The last texture listed will be the top
  16495. layer, the first one listed will be the bottom layer. All
  16496. textures in a layered texture other than the bottom layer should
  16497. have some transparency.  For example:
  16498.  
  16499.   object {
  16500.     My_Object
  16501.     texture {T1}  // the bottom layer
  16502.     texture {T2}  // a semi-transparent layer
  16503.     texture {T3}  // the top semi-transparent layer
  16504.   }
  16505. In this example T2 shows only where T3 is transparent and T1
  16506. shows only where T2 and T3 are transparent.
  16507.  
  16508. The color of underlying layers is filtered by upper layers but
  16509. the results do not look exactly like a series of transparent
  16510. surfaces. If you had a stack of surfaces with the textures
  16511. applied to each, the light would be filtered twice: once on the
  16512. way in as the lower layers are illuminated by filtered light and
  16513. once on the way out. Layered textures do not filter the
  16514. illumination on the way in. Other parts of the lighting
  16515. calculations work differently as well. The results look great and
  16516. allow for fantastic looking textures but they are simply
  16517. different from multiple surfaces. See stones.inc in the standard
  16518. include files directory for some magnificent layered textures.
  16519.  
  16520. Note layered textures must use the texture wrapped around any
  16521. pigment, normal or finish statements. Do not use multiple
  16522. pigment, normal or finish statements without putting them inside
  16523. the texture statement.
  16524.  
  16525. Layered textures may be declared. For example
  16526.  
  16527.   #declare Layered_Examp =
  16528.     texture {T1}
  16529.     texture {T2}
  16530.     texture {T3}
  16531. may be invoked as follows:
  16532.  
  16533.   object {
  16534.     My_Object
  16535.     texture {
  16536.       Layer_Examp
  16537.       // Any pigment, normal or finish here
  16538.       // modifies the bottom layer only.
  16539.     }
  16540.   }
  16541. If you wish to use a layered texture in a block pattern, such as
  16542. checker, hexagon, or brick, or in a material_map, you must
  16543. declare it first and then reference it inside a single texture
  16544. statement. A patterned texture cannot be used as a layer in a
  16545. layered texture however you may use layered textures as any of
  16546. the textures contained within a patterned texture.
  16547.  
  16548.  
  16549. 4.7.7     Patterns
  16550. POV-Ray uses a method called three-dimensional solid texturing to
  16551. define the color, bumpiness and other properties of an object.
  16552. You specify the way that the texture varies over a surface by
  16553. specifying a pattern.  Patterns are used in pigments, normals and
  16554. texture maps as well as media density.
  16555.  
  16556. All patterns in POV-Ray are three dimensional. For every point in
  16557. space, each pattern has a unique value. Patterns do not wrap
  16558. around a surface like putting wallpaper on an object. The
  16559. patterns exist in 3d and the objects are carved from them like
  16560. carving an object from a solid block of wood or stone.
  16561.  
  16562. Consider a block of wood. It contains light and dark bands that
  16563. are concentric cylinders being the growth rings of the wood. On
  16564. the end of the block you see these concentric circles. Along its
  16565. length you see lines that are the veins. However the pattern
  16566. exists throughout the entire block. If you cut or carve the wood
  16567. it reveals the pattern inside. Similarly an onion consists of
  16568. concentric spheres that are visible only when you slice it.
  16569. Marble stone consists of wavy layers of colored sediments that
  16570. harden into rock.
  16571.  
  16572. These solid patterns can be simulated using mathematical
  16573. functions. Other random patterns such as granite or bumps and
  16574. dents can be generated using a random number system and a noise
  16575. function.
  16576.  
  16577. In each case, the x, y, z coordinate of a point on a surface is
  16578. used to compute some mathematical function that returns a float
  16579. value. When used with color maps or pigment maps, that value
  16580. looks up the color of the pigment to be used. In normal
  16581. statements the pattern function result modifies or perturbs the
  16582. surface normal vector to give a bumpy appearance. Used with a
  16583. texture map, the function result determines which combinations of
  16584. entire textures to be used.  When used with media density it
  16585. specifies the density of the particles or gasses.
  16586.  
  16587. The following sections describe each pattern. See the sections
  16588. "Pigment", "Normal", "Patterned Textures" and "Density" for more
  16589. details on how to use patterns. Unless mentioned otherwise, all
  16590. patterns use the ramp_wave wave type by default but may use any
  16591. wave type and may be used with color_map, pigment_map,
  16592. normal_map, slope_map, texture_map, density, and density_map.
  16593.  
  16594.  
  16595. 4.7.7.1   Agate
  16596. The agate pattern is a banded pattern similar to marble but it
  16597. uses a specialized built-in turbulence function that is different
  16598. from the traditional turbulence. The traditional turbulence can
  16599. be used as well but it is generally not necessary because agate
  16600. is already very turbulent. You may control the amount of the
  16601. built-in turbulence by adding the optional agate_turb keyword
  16602. followed by a float value. For example:
  16603.  
  16604.   pigment {
  16605.     agate
  16606.     agate_turb 0.5
  16607.     color_map {MyMap}
  16608.   }
  16609.  
  16610. 4.7.7.2   Average
  16611. Technically average is not a pattern type but it is listed here
  16612. because the syntax is similar to other patterns. Typically a
  16613. pattern type specifies how colors or normals are chosen from a
  16614. pigment_mapâ•• texture_map, density_map, or normal_map, however
  16615. average tells POV-Ray to average together all of the patterns you
  16616. specify.  Average was originally designed to be used in a normal
  16617. statement with a normal_map as a method of specifying more than
  16618. one normal pattern on the same surface. However average may be
  16619. used in a pigment statement with a pigment_map or in a texture
  16620. statement with a texture_map or media density with density_map to
  16621. average colors too.
  16622.  
  16623. When used with pigments, the syntax is:
  16624.  
  16625. AVERAGED_PIGMENT:
  16626.   pigment {
  16627.     pigment_map{ PIGMENT_MAP_ENTRY... }
  16628.   }
  16629. PIGMENT_MAP_ENTRY:
  16630.   [ [Weight]  PIGMENT_BODY ]
  16631. Where Weight is an optional float value that defaults to 1.0 if
  16632. not specified.  This weight value is the relative weight applied
  16633. to that pigment.  Each PIGMENT_BODY is anything which can be
  16634. inside a pigment{...} statement.  The pigment keyword and {}
  16635. braces need not be specified.
  16636.  
  16637. Note that the [] brackets are part of the actual
  16638. PIGMENT_MAP_ENTRY. They are not notational symbols denoting
  16639. optional parts. The brackets surround each entry in the
  16640. pigment_map. There may be from 2 to 256 entries in the map.
  16641.  
  16642. For example
  16643.  
  16644.     pigment {
  16645.       average
  16646.       pigment_map {
  16647.         [1.0  Pigment_1]
  16648.         [2.0  Pigment_2]
  16649.         [0.5  Pigment_3]
  16650.       }
  16651.     }
  16652. All three pigments are evaluated.  The weight values are
  16653. multiplied by the resulting color.  It is then divided by the
  16654. total of the weights which, in this example is 3.5.  When used
  16655. with texture_map or density_map it works the same way.
  16656.  
  16657. When used with a normal_map in a normal statement, multiple
  16658. copies of the original surface normal are created and are
  16659. perturbed by each pattern. The perturbed normals are then
  16660. weighted, added and normalized.
  16661.  
  16662. See the sections "Pigment Maps and Pigment Lists", "Normal Maps
  16663. and Normal Lists", "Texture Maps", and "Density Maps and Density
  16664. Lists" for more information.
  16665.  
  16666.  
  16667. 4.7.7.3   Boxed
  16668. The boxed pattern creates a 2x2x2 unit cube centered at the
  16669. origin.  It is computed by:
  16670.  
  16671.   value =1.0- min(1, max(abs(X), abs(Y), abs(Z)))
  16672.  
  16673. It starts at 1.0 at the origin and increases to a minimum value
  16674. of 0.0 as it approaches any plane which is one unit from the
  16675. origin.  It remains at 0.0 for all areas beyond that distance.
  16676. This pattern was originally created for use with halo or media
  16677. but it may be used anywhere any pattern may be used.
  16678.  
  16679.  
  16680. 4.7.7.4   Bozo
  16681. The bozo pattern is a very smooth, random noise function that is
  16682. traditionally used with some turbulence to create clouds. The
  16683. spotted pattern is identical to bozo but in early versions of POV-
  16684. Ray spotted did not allow turbulence to be added. Turbulence can
  16685. now be added to any pattern so these are redundant but both are
  16686. retained for backwards compatibility. The bumps pattern is also
  16687. identical to bozo when used anywhere except in a normal
  16688. statement. When used as a normal pattern, bumps uses a slightly
  16689. different method to perturb the normal with a similar noise
  16690. function.
  16691.  
  16692. The bozo noise function has the following properties:
  16693.  
  16694.   1.  It's defined over 3D space i.e., it takes x, y, and z and
  16695.   returns the noise value there.
  16696.   2.  If two points are far apart, the noise values at those
  16697.   points are relatively random.
  16698.   3.  If two points are close together, the noise values at those
  16699.   points are close to each other.
  16700. You can visualize this as having a large room and a thermometer
  16701. that ranges from 0.0 to 1.0. Each point in the room has a
  16702. temperature. Points that are far apart have relatively random
  16703. temperatures. Points that are close together have close
  16704. temperatures. The temperature changes smoothly but randomly as we
  16705. move through the room.
  16706.  
  16707. Now let's place an object into this room along with an artist.
  16708. The artist measures the temperature at each point on the object
  16709. and paints that point a different color depending on the
  16710. temperature.  What do we get? A POV-Ray bozo texture!
  16711.  
  16712.  
  16713. 4.7.7.5   Brick
  16714. The brick pattern generates a pattern of bricks. The bricks are
  16715. offset by half a brick length on every other row in the x- and z-
  16716. directions. A layer of mortar surrounds each brick. The syntax is
  16717. given by
  16718.  
  16719.     pigment {
  16720.       brick COLOR_1, COLOR_2
  16721.       [brick_size <Size>]
  16722.       [mortar Size]
  16723.     }
  16724. where COLOR_1 is the color of the mortar and COLOR_2 is the color
  16725. of the brick itself. If no colors are specified a default deep
  16726. red and dark gray are used. The default size of the brick and
  16727. mortar together is <8, 3, 4.5> units. The default thickness of
  16728. the mortar is 0.5 units. These values may be changed using the
  16729. optional brick_size and mortar pattern modifiers. You may also
  16730. use pigment statements in place of the colors. For example:
  16731.  
  16732.   pigment {
  16733.     brick pigment{Jade}, pigment{Black_Marble}
  16734.   }
  16735. This example uses normals:
  16736.  
  16737.   normal { brick 0.5 }
  16738. The float value is an optional bump size. You may also use full
  16739. normal statements. For example:
  16740.  
  16741.   normal {
  16742.     brick normal{bumps 0.2}, normal{granite 0.3}
  16743.   }
  16744. When used with textures, the syntax is
  16745.  
  16746.   texture {
  16747.     brick texture{T_Gold_1A}, texture{Stone12}
  16748.   }
  16749. This is a block pattern which cannot use wave types, color_map,
  16750. or slope_map modifiers.
  16751.  
  16752.  
  16753. 4.7.7.6   Bumps
  16754. The bumps pattern was originally designed only to be used as a
  16755. normal pattern. It uses a very smooth, random noise function that
  16756. creates the look of rolling hills when scaled large or a bumpy
  16757. orange peal when scaled small. Usually the bumps are about 1 unit
  16758. apart.
  16759.  
  16760. When used as a normal pattern, this pattern uses a specialized
  16761. normal perturbation function. This means that the pattern cannot
  16762. be used with normal_map, slope_map or wave type modifiers in a
  16763. normal statement.
  16764.  
  16765. When used as a pigment pattern or texture pattern, the bumps
  16766. pattern is identical to bozo or spotted and is similar to normal
  16767. bumps but is not identical as are most normals when compared to
  16768. pigments.
  16769.  
  16770.  
  16771. 4.7.7.7   Checker
  16772. The checker pattern produces a checkered pattern consisting of
  16773. alternating squares of two colors.  The syntax is:
  16774.  
  16775.   pigment { checker [COLOR_1 [, COLOR_2]] [PATTERN_MODIFIERS...]
  16776.   }
  16777. If no colors are specified then default blue and green colors are
  16778. used.
  16779.  
  16780. The checker pattern is actually a series of cubes that are one
  16781. unit in size. Imagine a bunch of 1 inch cubes made from two
  16782. different colors of modeling clay. Now imagine arranging the
  16783. cubes in an alternating check pattern and stacking them in layer
  16784. after layer so that the colors still alternate in every
  16785. direction. Eventually you would have a larger cube. The pattern
  16786. of checks on each side is what the POV-Ray checker pattern
  16787. produces when applied to a box object.  Finally imagine cutting
  16788. away at the cube until it is carved into a smooth sphere or any
  16789. other shape. This is what the checker pattern would look like on
  16790. an object of any kind.
  16791.  
  16792. You may also use pigment statements in place of the colors. For
  16793. example:
  16794.  
  16795.   pigment { checker pigment{Jade}, pigment{Black_Marble} }
  16796. This example uses normals:
  16797.  
  16798.   normal { checker 0.5 }
  16799. The float value is an optional bump size. You may also use full
  16800. normal statements. For example:
  16801.  
  16802.   normal {
  16803.     checker normal{gradient x scale .2},
  16804.             normal{gradient y scale .2}
  16805.   }
  16806. When used with textures, the syntax is
  16807.  
  16808.   texture { checker texture{T_Wood_3A},texture{Stone12} }
  16809. This use of checker as a texture pattern replaces the special
  16810. tiles texture in previous versions of POV-Ray. You may still use
  16811. tiles but it may be phased out in future versions so checker
  16812. textures are best.
  16813.  
  16814. This is a block pattern which cannot use wave types, color_map,
  16815. or slope_map modifiers.
  16816.  
  16817.  
  16818. 4.7.7.8   Crackle
  16819. The crackle pattern is a set of random tiled polygons. With a
  16820. large scale and no turbulence it makes a pretty good stone wall
  16821. or floor. With a small scale and no turbulence it makes a pretty
  16822. good crackle ceramic glaze. Using high turbulence it makes a good
  16823. marble that avoids the problem of apparent parallel layers in
  16824. traditional marble.
  16825.  
  16826. Mathematically, the set crackle(p)=0 is a 3D Voronoi diagram of a
  16827. field of semi random points and crackle(p) < 0 is the distance
  16828. from the set along the shortest path (a Voronoi diagram is the
  16829. locus of points equidistant from their two nearest neighbors from
  16830. a set of disjoint points, like the membranes in suds are to the
  16831. centers of the bubbles).
  16832.  
  16833.  
  16834. 4.7.7.9   Cylindrical
  16835. The cylindrical pattern creates a one unit radius cylinder along
  16836. the Y axis.  It is computed by:
  16837.  
  16838.   value = 1.0-min(1, sqrt(X^2 + Z^2))
  16839.  
  16840. It starts at 1.0 at the origin and increases to a minimum value
  16841. of 0.0 as it approaches a distance of 1 unit from the Y axis.  It
  16842. remains at 0.0 for all areas beyond that distance.  This pattern
  16843. was originally created for use with halo or media but it may be
  16844. used anywhere any pattern may be used.
  16845.  
  16846.  
  16847. 4.7.7.10  Density_File
  16848. The density_file pattern is a 3-D bitmap pattern that occupies a
  16849. unit cube from location <0,0,0> to <1,1,1>.  The data file is a
  16850. raw binary file format created for POV-Ray called df3 format.
  16851. The syntax provides for the possibility of implementing other
  16852. formats in the future.  This pattern was originally created for
  16853. use with halo or media but it may be used anywhere any pattern
  16854. may be used.  The syntax is:
  16855.  
  16856.   pigment {density_file df3 "filename.df3" [interpolate Type]
  16857.   [PIGMENT_MODIFIERS...] }
  16858. where "filename.df3" is a file name of the data file.
  16859.  
  16860. As a normal pattern, the syntax is
  16861.  
  16862.   normal {density_file df3 "filename.df3"  [, Bump_Size]
  16863.      [interpolate Type] [NORMAL_MODIFIERS...]
  16864.   }
  16865. The optional float Bump_Size should follow the file name and any
  16866. other modifiers follow that.
  16867.  
  16868. The df3 format consists of a 6 byte header of three 16-bit
  16869. integers with high order byte first.  These three values give the
  16870. x,y,z size of the data in pixels (or more appropriately called
  16871. voxels).  This is followed by x*y*z unsigned integer bytes of
  16872. data.  The data in the range of 0 to 255 is scaled into a float
  16873. value in the range 0.0 to 1.0.  It remains at 0.0 for all areas
  16874. beyond the unit cube.  The pattern occupies the unit cube
  16875. regardless of the dimensions in voxels.
  16876.  
  16877. The interpolate keyword may be specified to add interpolation of
  16878. the data.  The default value of zero specifies no interpolation.
  16879. A value of one specifies tri-linear interpolation.
  16880.  
  16881. See the sample scenes for data file include\spiral.df3,and the
  16882. scenes which use it: scenes\textures\surfaces\densfile.pov,
  16883. scenes\interior\media\galaxy.pov for examples.
  16884.  
  16885.  
  16886. 4.7.7.11  Dents
  16887. The dents pattern was originally designed only to be used as a
  16888. normal pattern. It is especially interesting when used with
  16889. metallic textures. It gives impressions into the metal surface
  16890. that look like dents have been beaten into the surface with a
  16891. hammer. Usually the dents are about 1 unit apart.
  16892.  
  16893. When used as a normal pattern, this pattern uses a specialized
  16894. normal perturbation function. This means that the pattern cannot
  16895. be used with normal_map, slope_map or wave type modifiers in a
  16896. normal statement.
  16897.  
  16898. When used as a pigment pattern or texture pattern, the dents
  16899. pattern is similar to normal dents but is not identical as are
  16900. most normals when compared to pigments.
  16901.  
  16902.  
  16903. 4.7.7.12  Gradient
  16904. One of the simplest patterns is the gradient pattern. It is
  16905. specified as
  16906.  
  16907.   pigment {gradient <Orientation> [PIGMENT_MODIFIERS...] }
  16908. where <Orientation> is a vector pointing in the direction that
  16909. the colors blend. For example
  16910.  
  16911.    pigment { gradient x } // bands of color vary as you move
  16912.                           // along the "x" direction.
  16913. produces a series of smooth bands of color that look like layers
  16914. of colors next to each other. Points at x=0 are the first color
  16915. in the color map. As the x location increases it smoothly turns
  16916. to the last color at x=1. Then it starts over with the first
  16917. again and gradually turns into the last color at x=2. The pattern
  16918. reverses for negative values of x. Using gradient y or gradient z
  16919. makes the colors blend along the y- or z-axis. Any vector may be
  16920. used but x, y and z are most common.
  16921.  
  16922. As a normal pattern, gradient generates a saw-tooth or ramped
  16923. wave appearance. The syntax is
  16924.  
  16925.   normal {gradient <Orientation> [, Bump_Size]
  16926.   [NORMAL_MODIFIERS...] }
  16927. where the vector <Orientation> is a required parameter but the
  16928. float Bump_Size which follows is optional.  Note that the comma
  16929. is required especially if Bump_Size is negative.
  16930.  
  16931.  
  16932. 4.7.7.13  Granite
  16933. The granite pattern uses a simple 1/f fractal noise function to
  16934. give a good granite pattern. This pattern is used with creative
  16935. color maps in stones.inc to create some gorgeous layered stone
  16936. textures.
  16937.  
  16938. As a normal pattern it creates an extremely bumpy surface that
  16939. looks like a gravel driveway or rough stone.
  16940.  
  16941.  
  16942. 4.7.7.14  Hexagon
  16943. The hexagon pattern is a block pattern that generates a repeating
  16944. pattern of hexagons in the x-y-plane. In this instance imagine
  16945. tall rods that are hexagonal in shape and are parallel to the y-
  16946. axis and grouped in bundles like shown in the example image.
  16947. Three separate colors should be specified as follows:
  16948.  
  16949.   pigment{hexagon [COLOR_1 [, COLOR_2 [, COLOR_3]]]
  16950.   [PATTERN_MODIFIERS...] }
  16951.                                 
  16952.                       The hexagon pattern.
  16953. The three colors will repeat the hexagonal pattern with hexagon
  16954. COLOR_1 centered at the origin, COLOR_2 in the +z-direction and
  16955. COLOR_3 to either side. Each side of the hexagon is one unit
  16956. long.  The hexagonal rods of color extend infinitely in the +y-
  16957. and -y-directions. If no colors are specified then default blue,
  16958. green and red colors are used.
  16959.  
  16960. You may also use pigment statements in place of the colors. For
  16961. example:
  16962.  
  16963.   pigment {
  16964.     hexagon pigment { Jade },
  16965.             pigment { White_Marble },
  16966.             pigment { Black_Marble }
  16967.   }
  16968. This example uses normals:
  16969.  
  16970.   normal { hexagon 0.5 }
  16971. The float value is an optional bump size. You may also use full
  16972. normal statements. For example:
  16973.  
  16974.   normal {
  16975.     hexagon
  16976.       normal { gradient x scale .2 },
  16977.       normal { gradient y scale .2 },
  16978.       normal { bumps scale .2 }
  16979.   }
  16980. When used with textures, the syntax is...
  16981.  
  16982.   texture {
  16983.     hexagon
  16984.       texture { T_Gold_3A },
  16985.       texture { T_Wood_3A },
  16986.       texture { Stone12 }
  16987.   }
  16988. This is a block pattern which cannot use wave types, color_map,
  16989. or slope_map modifiers.
  16990.  
  16991.  
  16992. 4.7.7.15  Leopard
  16993. Leopard creates regular geometric pattern of circular spots.  The
  16994. formula used is:
  16995.  
  16996.    value = Sqr((sin(x)+sin(y)+sin(z))/3)
  16997.  
  16998.  
  16999. 4.7.7.16  Mandel
  17000. The mandel pattern computes the standard Mandelbrot fractal
  17001. pattern and projects it onto the x-y-plane. It uses the x and y
  17002. coordinates to compute the Mandelbrot set.
  17003.  
  17004. It is specified as
  17005.  
  17006.   pigment {mandel Max_Iteration [PIGMENT_MODIFIERS...] }
  17007. The pattern is specified with the keyword mandel followed by an
  17008. integer number. This number is the maximum number of iterations
  17009. to be used to compute the set. Typical values range from 10 up to
  17010. 256 but any positive integer may be used. For example:
  17011.  
  17012.   pigment {
  17013.     mandel 25
  17014.     color_map {
  17015.       [0.0  color Cyan]
  17016.       [0.3  color Yellow]
  17017.       [0.6  color Magenta]
  17018.       [1.0  color Cyan]
  17019.     }
  17020.     scale .5
  17021.   }
  17022. The value passed to the color map is computed by the formula:
  17023.  
  17024.   value = number_of_iterations / max_iterations
  17025.  
  17026. When used as a normal pattern, the syntax is...
  17027.  
  17028.   normal{mandel Max_Iteration [, Bump_Size]
  17029.   [NORMAL_MODIFIERS...] }
  17030. where the integer Max_Iteration is a required parameter but the
  17031. float Bump_Size which follows is optional.  Note that the comma
  17032. is required especially if Bump_Size is negative.
  17033.  
  17034.  
  17035. 4.7.7.17  Marble
  17036. The marble pattern is very similar to the gradient x pattern. The
  17037. gradient pattern uses a default ramp_wave wave type which means
  17038. it uses colors from the color map from 0.0 up to 1.0 at location
  17039. x=1 but then jumps back to the first color for x > 1 and repeats
  17040. the pattern again and again. However the marble pattern uses the
  17041. triangle_wave wave type in which it uses the color map from 0 to
  17042. 1 but then it reverses the map and blends from 1 back to zero.
  17043. For example:
  17044.  
  17045.   pigment {
  17046.     gradient x
  17047.     color_map {
  17048.       [0.0  color Yellow]
  17049.       [1.0  color Cyan]
  17050.     }
  17051.   }
  17052. This blends from yellow to cyan and then it abruptly changes back
  17053. to yellow and repeats. However replacing gradient x with marble
  17054. smoothly blends from yellow to cyan as the x coordinate goes from
  17055. 0.0 to 0.5 and then smoothly blends back from cyan to yellow by
  17056. x=1.0.
  17057.  
  17058. Earlier versions of POV-Ray did not allow you to change wave
  17059. types.  Now that wave types can be changed for most any pattern,
  17060. the distinction between marble and gradient x is only a matter of
  17061. default wave types.
  17062.  
  17063. When used with turbulence and an appropriate color map, this
  17064. pattern looks like veins of color of real marble, jade or other
  17065. types of stone. By default, marble has no turbulence.
  17066.  
  17067.  
  17068. 4.7.7.18  Onion
  17069. The onion is a pattern of concentric spheres like the layers of
  17070. an onion.
  17071.  
  17072.   Value = mod(sqrt(Sqr(X)+Sqr(Y)+Sqr(Z)), 1.0)
  17073.  
  17074. Each layer is one unit thick.
  17075.  
  17076.  
  17077. 4.7.7.19  Planar
  17078. The planar pattern creates a horizontal stripe plus or minus one
  17079. unit above and below the X-Z plane.  It is computed by:
  17080.  
  17081.   value =1.0- min(1, abs(Y))
  17082.  
  17083. It starts at 1.0 at the origin and increases to a minimum value
  17084. of 0.0 as the Y values approaches a distance of 1 unit from the X-
  17085. Z plane.  It remains at 0.0 for all areas beyond that distance.
  17086. This pattern was originally created for use with halo or media
  17087. but it may be used anywhere any pattern may be used.
  17088.  
  17089.  
  17090. 4.7.7.20  Quilted
  17091. The quilted pattern was originally designed only to be used as a
  17092. normal pattern. The quilted pattern is so named because it can
  17093. create a pattern somewhat like a quilt or a tiled surface. The
  17094. squares are actually 3-D cubes that are 1 unit in size.
  17095.  
  17096. When used as a normal pattern, this pattern uses a specialized
  17097. normal perturbation function. This means that the pattern cannot
  17098. be used with normal_map, slope_map or wave type modifiers in a
  17099. normal statement.
  17100.  
  17101. When used as a pigment pattern or texture pattern, the quilted
  17102. pattern is similar to normal quilted but is not identical as are
  17103. most normals when compared to pigments.
  17104.  
  17105. The two parameters control0 and control1 are used to adjust the
  17106. curvature of the seam or gouge area between the quilts.  The
  17107. syntax is:
  17108.  
  17109. It is specified as
  17110.  
  17111.   pigment {quilted [QUILTED_MODIFIERS...] }
  17112. QUILTED_MODIFIERS:
  17113.   control0 Value_0   |   control Value_1   |   PIGMENT_MODIFIERS
  17114. The values should generally be kept to around the 0.0 to 1.0
  17115. range.  The default value is 1.0 if none is specified. Think of
  17116. this gouge between the tiles in cross-section as a sloped line.
  17117.  
  17118.                                 
  17119.      Quilted pattern with c0=0 and different values for c1.
  17120.                                 
  17121.     Quilted pattern with c0=0.33 and different values for c1.
  17122.                                 
  17123.     Quilted pattern with c0=0.67 and different values for c1.
  17124.                                 
  17125.      Quilted pattern with c0=1 and different values for c1.
  17126. This straight slope can be made to curve by adjusting the two
  17127. control values. The control values adjust the slope at the top
  17128. and bottom of the curve. A control values of 0 at both ends will
  17129. give a linear slope, as shown above, yielding a hard edge. A
  17130. control value of 1 at both ends will give an "s" shaped curve,
  17131. resulting in a softer, more rounded edge.
  17132.  
  17133.  
  17134. 4.7.7.21  Radial
  17135. The radial pattern is a radial blend that wraps around the +y-
  17136. axis. The color for value 0.0 starts at the +x-direction and
  17137. wraps the color map around from east to west with 0.25 in the -z-
  17138. direction, 0.5 in -x, 0.75 at +z and back to 1.0 at +x. Typically
  17139. the pattern is used with a frequency modifier to create multiple
  17140. bands that radiate from the y-axis.  For example:
  17141.  
  17142.   pigement {
  17143.     radial color_map{[0.5 Black][0.5 White]}
  17144.     frequency 10
  17145.   }
  17146. creates 10 white bands and 10 black bands radiating from the y
  17147. axis.
  17148.  
  17149.  
  17150. 4.7.7.22  Ripples
  17151. The ripples pattern was originally designed only to be used as a
  17152. normal pattern. It makes the surface look like ripples of water.
  17153. The ripples radiate from 10 random locations inside the unit cube
  17154. area <0,0,0> to <1,1,1>. Scale the pattern to make the centers
  17155. closer or farther apart.
  17156.  
  17157. Usually the ripples from any given center are about 1 unit apart.
  17158. The frequency keyword changes the spacing between ripples. The
  17159. phase keyword can be used to move the ripples outwards for
  17160. realistic animation.
  17161.  
  17162. The number of ripple centers can be changed with the global
  17163. parameter
  17164.  
  17165.   global_settings{number_of_waves Count }
  17166. somewhere in the scene. This affects the entire scene. You cannot
  17167. change the number of wave centers on individual patterns. See
  17168. section "Number_Of_Waves" for details.
  17169.  
  17170. When used as a normal pattern, this pattern uses a specialized
  17171. normal perturbation function. This means that the pattern cannot
  17172. be used with normal_map, slope_map or wave type modifiers in a
  17173. normal statement.
  17174.  
  17175. When used as a pigment pattern or texture pattern, the ripples
  17176. pattern is similar to normal ripples but is not identical as are
  17177. most normals when compared to pigments.
  17178.  
  17179.  
  17180. 4.7.7.23  Spherical
  17181. The spherical pattern creates a one unit radius sphere along the
  17182. Y axis.  It is computed by:
  17183.  
  17184.   value = 1.0-min(1, sqrt(X^2 + Y^2 + Z^2))
  17185.  
  17186. It starts at 1.0 at the origin and increases to a max value of
  17187. 0.0 as it approaches a distance of 1 unit from the origin in any
  17188. direction.  It remains at 0.0 for all areas beyond that distance.
  17189. This pattern was originally created for use with halo or media
  17190. but it may be used anywhere any pattern may be used.
  17191.  
  17192.  
  17193. 4.7.7.24  Spiral1
  17194. The spiral1 pattern creates a spiral that winds around the y-axis
  17195. similar to a screw. When viewed sliced in the X-Z plane, it looks
  17196. like the spiral arms of a galaxy.  Its syntax is:
  17197.  
  17198.   pigment {spiral1 Number_of_Arms [PIGMENT_MODIFIERS...] }
  17199. The Number_of_Arms value determines how may arms are winding
  17200. around the y-axis.
  17201.  
  17202. As a normal pattern, the syntax is
  17203.  
  17204.   normal {spiral1 Number_of_Arms  [, Bump_Size]
  17205.   [NORMAL_MODIFIERS...] }
  17206. where the vector <Orientation> is a required parameter but the
  17207. float Bump_Size which follows is optional.  Note that the comma
  17208. is required especially if Bump_Size is negative.
  17209.  
  17210. The pattern uses the triangle_wave wave type by default but may
  17211. use any wave type.
  17212.  
  17213.  
  17214. 4.7.7.25  Spiral2
  17215. The spiral2 pattern creates a double spiral that winds around the
  17216. y-axis similar spiral1 except it is two overlapping spirals the
  17217. twist in opposite directions.  The results sometimes looks like a
  17218. basket weave or perhaps the skin of pineapple.  The center of a
  17219. sunflower also has a similar double spiral pattern.  Its syntax
  17220. is:
  17221.  
  17222.   pigment {spiral2 Number_of_Arms [PIGMENT_MODIFIERS...] }
  17223. The Number_of_Arms value determines how may arms are winding
  17224. around the y-axis.
  17225.  
  17226. As a normal pattern, the syntax is
  17227.  
  17228.   normal {spiral2 Number_of_Arms  [, Bump_Size]
  17229.   [NORMAL_MODIFIERS...] }
  17230. where the vector <Orientation> is a required parameter but the
  17231. float Bump_Size which follows is optional.  Note that the comma
  17232. is required especially if Bump_Size is negative.
  17233.  
  17234. The pattern uses the triangle_wave wave type by default but may
  17235. use any wave type.
  17236.  
  17237.  
  17238. 4.7.7.26  Spotted
  17239. The spotted pattern is identical to the bozo pattern. Early
  17240. versions of POV-Ray did not allow turbulence to be used with
  17241. spotted.  Now that any pattern can use turbulence there is no
  17242. difference between bozo and spotted. See section "Bozo" for
  17243. details.
  17244.  
  17245.  
  17246. 4.7.7.27  Waves
  17247. The waves pattern was originally designed only to be used as a
  17248. normal pattern. It makes the surface look like waves on water.
  17249. The waves pattern looks similar to the ripples pattern except the
  17250. features are rounder and broader. The effect is to make waves
  17251. that look more like deep ocean waves. The waves radiate from 10
  17252. random locations inside the unit cube area <0,0,0> to <1,1,1>.
  17253. Scale the pattern to make the centers closer or farther apart.
  17254.  
  17255. Usually the waves from any given center are about 1 unit apart.
  17256. The frequency keyword changes the spacing between waves. The
  17257. phase keyword can be used to move the waves outwards for
  17258. realistic animation.
  17259.  
  17260. The number of wave centers can be changed with the global
  17261. parameter
  17262.  
  17263.   global_settings{number_of_waves Count }
  17264. somewhere in the scene. This affects the entire scene. You cannot
  17265. change the number of wave centers on individual patterns. See
  17266. section "Number_Of_Waves" for details.
  17267.  
  17268. When used as a normal pattern, this pattern uses a specialized
  17269. normal perturbation function. This means that the pattern cannot
  17270. be used with normal_map, slope_map or wave type modifiers in a
  17271. normal statement.
  17272.  
  17273. When used as a pigment pattern or texture pattern, the waves
  17274. pattern is similar to normal waves but is not identical as are
  17275. most normals when compared to pigments.
  17276.  
  17277.  
  17278. 4.7.7.28  Wood
  17279. The wood pattern consists of concentric cylinders centered on the
  17280. z-axis. When appropriately colored, the bands look like the
  17281. growth rings and veins in real wood. Small amounts of turbulence
  17282. should be added to make it look more realistic. By default, wood
  17283. has no turbulence.
  17284.  
  17285. Unlike most patterns, the wood pattern uses the triangle_wave
  17286. wave type by default. This means that like marble, wood uses
  17287. color map values 0.0 to 1.0 then repeats the colors in reverse
  17288. order from 1.0 to 0.0. However you may use any wave type.
  17289.  
  17290.  
  17291. 4.7.7.29  Wrinkles
  17292. The wrinkles pattern was originally designed only to be used as a
  17293. normal pattern. It uses a 1/f noise pattern similar to granite
  17294. but the features in wrinkles are sharper. The pattern can be used
  17295. to simulate wrinkled cellophane or foil. It also makes an
  17296. excellent stucco texture.
  17297.  
  17298. When used as a normal pattern, this pattern uses a specialized
  17299. normal perturbation function. This means that the pattern cannot
  17300. be used with normal_map, slope_map or wave type modifiers in a
  17301. normal statement.
  17302.  
  17303. When used as a pigment pattern or texture pattern, the wrinkles
  17304. pattern is similar to normal wrinkles but is not identical as are
  17305. most normals when compared to pigments.
  17306.  
  17307.  
  17308. 4.7.8     Pattern Modifiers
  17309. Pattern modifiers are statements or parameters which modify how a
  17310. pattern is evaluated or tells what to do with the pattern. The
  17311. complete syntax is:
  17312.  
  17313. PATTERN_MODIFIER:
  17314.   BLEND_MAP_MODIFIER   |   AGATE_MODIFIER   |
  17315.   DENSITY_FILE_MODIFIER   |
  17316.   QUILTED_MODIFIER   |   BRICK_MODIFIER   |
  17317.   turbulence <Amount>   |   octaves Count   |   omega Amount   |
  17318.   lambda Amount   |
  17319.   warp { [WARP_ITEMS...] }   |
  17320.   TRANSFORMATION
  17321. BLEND_MAP_MODIFIER:
  17322.   frequency Amount   |   phase Amount   |
  17323.   ramp_wave   |   triangle_wave   |   sine_wave   |
  17324.   scallop_wave   |
  17325.   cubic_wave   |   poly_wave [Exponent]
  17326. AGATE_MODIFIER:
  17327.   agate_turb Value
  17328. BRICK_MODIFIER:
  17329.   brick_size Size   |   mortar Size
  17330. DENSITY_FILE_MODIFIER:
  17331.   interpolate Type
  17332. QUILTED_MODIFIER:
  17333.   control0 Value   |   control1 Value
  17334. PIGMENT_MODIFIER:
  17335.   PATTERN_MODIFIER   |   COLOR_LIST   |   PIGMENT_LIST   |
  17336.   color_map{ COLOR_MAP_BODY }   |   colour_map{ COLOR_MAP_BODY }
  17337.   |
  17338.   pigment_map{ PIGMENT_MAP_BODY }   |
  17339.   quick_color COLOR   |   quick_colour COLOR
  17340. NORMAL_MODIFIER:
  17341.   PATTERN_MODIFIER   |   NORMAL_LIST   |
  17342.   normal_map{ NORMAL_MAP_BODY }   |
  17343.   slope_map{ SLOPE_MAP_BODY }   |
  17344.   bump_size Amount
  17345. TEXTURE_PATTERN_MODIFIER:
  17346.   PATTERN_MODIFIER   |   TEXTURE_LIST   |
  17347.   texture_map{ TEXTURE_MAP_BODY }
  17348. DENSITY_MODIFIER:
  17349.   PATTERN_MODIFIER   |   DENSITY_LIST   |   COLOR_LIST   |
  17350.   color_map{ COLOR_MAP_BODY }   |   colour_map{ COLOR_MAP_BODY }
  17351.   |
  17352.   density_map{ DENSITY_MAP_BODY }
  17353. The modifiers PIGMENT_LIST, quick_color, and pigment_map apply
  17354. only to pigments. See section "Pigment" for details on these
  17355. pigment-specific pattern modifiers.
  17356.  
  17357. The modifiers COLOR_LIST and color_map apply only to pigments and
  17358. densities. See sections "Pigment" and "Density" for details on
  17359. these pigment-specific pattern modifiers.
  17360.  
  17361. The modifiers NORMAL_LIST, bump_size, slope_map and normal_map
  17362. apply only to normals. See section "Normal" for details on these
  17363. normal-specific pattern modifiers.
  17364.  
  17365. The TEXTURE_LIST and texture_map modifiers can only be used with
  17366. patterned textures. See section "Texture Maps" for details.
  17367.  
  17368. The DENSITY_LIST and density_map modifiers only work with
  17369. media{density{..}} statements.  See "Density" for details.
  17370.  
  17371. The agate_turb modifier can only be used with the agate pattern.
  17372. See "Agate" for details.
  17373.  
  17374. The brick_size and mortar modifiers can only be used with the
  17375. brick pattern.  See "Brick" for details.
  17376.  
  17377. The control0 and control1 modifiers can only be used with the
  17378. quilted pattern.  See "Quilted" for details.
  17379.  
  17380. The interpolate modifier can only be used with the density_file
  17381. pattern.  See "Density_File" for details.
  17382.  
  17383. The general purpose pattern modifiers in the following sections
  17384. can be used with pigment, normal, texture, or density patterns.
  17385.  
  17386.  
  17387. 4.7.8.1   Transforming Patterns
  17388. The most common pattern modifiers are the transformation
  17389. modifiers translate, rotate, scale, transform, and matrix.  For
  17390. details on these commands see section "Transformations".
  17391.  
  17392. These modifiers may be placed inside pigment, normal, texture,
  17393. and density statements to change the position, size and
  17394. orientation of the patterns.
  17395.  
  17396. Transformations are performed in the order in which you specify
  17397. them.  However in general the order of transformations relative
  17398. to other pattern modifiers such as turbulence, color_map and
  17399. other maps is not important. For example scaling before or after
  17400. turbulence makes no difference. The turbulence is done first,
  17401. then the scaling regardless of which is specified first. However
  17402. the order in which transformations are performed relative to warp
  17403. statements is important. See "Warps" for details.
  17404.  
  17405.  
  17406. 4.7.8.2   Frequency and Phase
  17407. The frequency and phase modifiers act as a type of scale and
  17408. translate modifiers for various blend maps.  They only have
  17409. effect when blend maps are used.  Blend maps are color_map,
  17410. pigment_map, normal_map, slope_map, density_map, and texture_map.
  17411. This discussion uses a color map as an example but the same
  17412. principles apply to the other blend map types.
  17413.  
  17414. The frequency keyword adjusts the number of times that a color
  17415. map repeats over one cycle of a pattern. For example gradient
  17416. covers color map values 0 to 1 over the range from x=0 to x=1. By
  17417. adding frequency 2.0 the color map repeats twice over that same
  17418. range. The same effect can be achieved using scale 0.5*x so the
  17419. frequency keyword isn't that useful for patterns like gradient.
  17420.  
  17421. However the radial pattern wraps the color map around the +y-axis
  17422. once. If you wanted two copies of the map (or 3 or 10 or 100)
  17423. you'd have to build a bigger map. Adding frequency 2.0 causes the
  17424. color map to be used twice per revolution. Try this:
  17425.  
  17426.   pigment {
  17427.     radial
  17428.     color_map{[0.5 color Red][0.5 color White]}
  17429.     frequency 6
  17430.   }
  17431. The result is six sets of red and white radial stripes evenly
  17432. spaced around the object.
  17433.  
  17434. The float after frequency can be any value. Values greater than
  17435. 1.0 causes more than one copy of the map to be used. Values from
  17436. 0.0 to 1.0 cause a fraction of the map to be used. Negative
  17437. values reverses the map.
  17438.  
  17439. The phase value causes the map entries to be shifted so that the
  17440. map starts and ends at a different place. In the example above if
  17441. you render successive frames at phase 0 then phase 0.1, phase
  17442. 0.2, etc. you could create an animation that rotates the stripes.
  17443. The same effect can be easily achieved by rotating the radial
  17444. pigment using rotate y*Angle but there are other uses where phase
  17445. can be handy.
  17446.  
  17447. Sometimes you create a great looking gradient or wood color map
  17448. but you want the grain slightly adjusted in or out. You could re-
  17449. order the color map entries but that's a pain. A phase adjustment
  17450. will shift everything but keep the same scale. Try animating a
  17451. mandel pigment for a color palette rotation effect.
  17452.  
  17453. These values work by applying the following formula
  17454.  
  17455.   New_Value = fmod ( Old_Value * Frequency + Phase, 1.0 ).
  17456.  
  17457. The frequency and phase modifiers have no effect on block
  17458. patterns checker, brick, and hexagon nor do they effect
  17459. image_map, bump_map or material_map. They also have no effect in
  17460. normal statements when used with bumps, dents, quilted or
  17461. wrinkles because these normal patterns cannot use normal_map or
  17462. slope_map.
  17463.  
  17464. They can be used with normal patterns ripples and waves even
  17465. though these two patterns cannot use normal_map or slope_map
  17466. either. When used with ripples or waves, frequency adjusts the
  17467. space between features and phase can be adjusted from 0.0 to 1.0
  17468. to cause the ripples or waves to move relative to their center
  17469. for animating the features.
  17470.  
  17471.  
  17472. 4.7.8.3   Waveforms
  17473. POV-Ray allows you to apply various wave forms to the pattern
  17474. function before applying it to a blend map. Blend maps are
  17475. color_map, pigment_map, normal_map, slope_map, density_map, and
  17476. texture_map.
  17477.  
  17478. Most of the patterns which use a blend map, use the entries in
  17479. the map in order from 0.0 to 1.0. The effect can most easily be
  17480. seen when these patterns are used as normal patterns with no
  17481. maps.  Patterns such as gradient or onion generate a grove or
  17482. slot that looks like a ramp that drops off sharply.  This is
  17483. called a  ramp_wave wave type and it is the default wave type for
  17484. most patterns. However the wood and marble patterns use the map
  17485. from 0.0 to 1.0 and then reverses it and runs it from 1.0 to 0.0.
  17486. The result is a wave form which slopes upwards to a peak, then
  17487. slopes down again in a triangle_wave. In earlier versions of POV-
  17488. Ray there was no way to change the wave types. You could simulate
  17489. a triangle wave on a ramp wave pattern by duplicating the map
  17490. entries in reverse, however there was no way to use a ramp wave
  17491. on wood or marble.
  17492.  
  17493. Now any pattern that takes a map can have the default wave type
  17494. overridden. For example:
  17495.  
  17496.   pigment { wood color_map { MyMap } ramp_wave }
  17497. Also available are sine_wave, scallop_wave, cubic_wave and
  17498. poly_wave types. These types are of most use in normal patterns
  17499. as a type of built-in slope map. The  sine_wave takes the zig-zag
  17500. of a ramp wave and turns it into a gentle rolling wave with
  17501. smooth transitions. The scallop_wave uses the absolute value of
  17502. the sine wave which looks like corduroy when scaled small or like
  17503. a stack of cylinders when scaled larger.  The cubic_wave is a
  17504. gentle cubic curve from 0.0 to 1.0 with zero slope at the start
  17505. and end.  The poly_wave is an exponential function.  It is
  17506. followed by an optional float value which specifies exponent.
  17507. For example poly_wave 2 starts low and climbs rapidly at the end
  17508. while poly_wave 0.5 climbs rapidly at first and levels off at the
  17509. end.  If no float value is specified, the default is 1.0 which
  17510. produces a linear function identical to ramp_wave.
  17511.  
  17512. Although any of these wave types can be used for pigments,
  17513. normals, textures, or density the effect of many of the wave
  17514. types are not as noticeable on pigments, textures, or density as
  17515. they are for normals.
  17516.  
  17517. Wave type modifiers have no effect on block patterns checker,
  17518. brick, and hexagon nor do they effect image_map, bump_map or
  17519. material_map. They also have no effect in normal statements when
  17520. used with bumps, dents, quilted, ripples, waves, or wrinkles
  17521. because these normal patterns cannot use normal_map or slope_map.
  17522.  
  17523.  
  17524. 4.7.8.4   Turbulence
  17525. The keyword turbulence followed by a float or vector may be used
  17526. to stir up any pigment, normal, texture, irid or density. A
  17527. number of optional parameters may be used with turbulence to
  17528. control how it is computed. The syntax is:
  17529.  
  17530. TURBULENCE_ITEM:
  17531.   turbulence <Amount>   |   octaves Count   |   omega Amount   |
  17532.   lambda Amount
  17533. Typical turbulence values range from the default 0.0, which is no
  17534. turbulence, to 1.0 or more, which is very turbulent. If a vector
  17535. is specified different amounts of turbulence are applied in the x-
  17536. , y- and z-direction. For example
  17537.  
  17538.   turbulence <1.0, 0.6, 0.1>
  17539. has much turbulence in the x-direction, a moderate amount in the
  17540. y-direction and a small amount in the z-direction.
  17541.  
  17542. Turbulence uses a random noise function called DNoise. This is
  17543. similar to the noise used in the bozo pattern except that instead
  17544. of giving a single value it gives a direction. You can think of
  17545. it as the direction that the wind is blowing at that spot. Points
  17546. close together generate almost the same value but points far
  17547. apart are randomly different.
  17548.  
  17549. In general the order of turbulence parameters relative to other
  17550. pattern modifiers such as transformations, color maps and other
  17551. maps is not important. For example scaling before or after
  17552. turbulence makes no difference. The turbulence is done first,
  17553. then the scaling regardless of which is specified first. See
  17554. section "" for a way to work around this behavior.
  17555.  
  17556. In general, the order of turbulence parameters relative to each
  17557. other and to other pattern modifiers such as transformations or
  17558. color_map and other maps is not important. For example scaling
  17559. before or after turbulence makes no difference. The turbulence is
  17560. done first, then the scaling regardless of which is specified
  17561. first. However the order in which transformations are performed
  17562. relative to warp statements is important. You can also specify
  17563. turbulence inside warp and in this way you can force turbulence
  17564. to be applied after transformations.  See "Warps" for details.
  17565.  
  17566. Turbulence uses DNoise to push a point around in several steps
  17567. called octaves. We locate the point we want to evaluate, then
  17568. push it around a bit using turbulence to get to a different point
  17569. then look up the color or pattern of the new point.
  17570.  
  17571. It says in effect "Don't give me the color at this spot... take a
  17572. few random steps in different directions and give me that color".
  17573. Each step is typically half as long as the one before. For
  17574. example:
  17575.  
  17576.                                 
  17577.                      Turbulence random walk.
  17578. The magnitude of these steps is controlled by the turbulence
  17579. value. There are three additional parameters which control how
  17580. turbulence is computed. They are octaves, lambda and omega. Each
  17581. is optional. Each is followed by a single float value. Each has
  17582. no effect when there is no turbulence.
  17583.  
  17584.  
  17585. 4.7.8.5   Octaves
  17586. The octaves keyword may be followed by an integer value to
  17587. control the number of steps of turbulence that are computed.
  17588. Legal values range from 1 to 10. The default value of 6 is a
  17589. fairly high value; you won't see much change by setting it to a
  17590. higher value because the extra steps are too small. Float values
  17591. are truncated to integer. Smaller numbers of octaves give a
  17592. gentler, wavy turbulence and computes faster. Higher octaves
  17593. create more jagged or fuzzy turbulence and takes longer to
  17594. compute.
  17595.  
  17596.  
  17597. 4.7.8.6   Lambda
  17598. The lambda parameter controls how statistically different the
  17599. random move of an octave is compared to its previous octave. The
  17600. default value is 2.0 which is quite random. Values close to
  17601. lambda 1.0 will straighten out the randomness of the path in the
  17602. diagram above. The zig-zag steps in the calculation are in nearly
  17603. the same direction. Higher values can look more swirly under some
  17604. circumstances.
  17605.  
  17606.  
  17607. 4.7.8.7   Omega
  17608. The omega value controls how large each successive octave step is
  17609. compared to the previous value. Each successive octave of
  17610. turbulence is multiplied by the omega value. The default omega
  17611. 0.5 means that each octave is 1/2 the size of the previous one.
  17612. Higher omega values mean that 2nd, 3rd, 4th and up octaves
  17613. contribute more turbulence giving a sharper, crinkly look while
  17614. smaller omegas give a fuzzy kind of turbulence that gets blurry
  17615. in places.
  17616.  
  17617.  
  17618. 4.7.8.8   Warps
  17619. The warp statement is a pattern modifier that is similar to
  17620. turbulence. Turbulence works by taking the pattern evaluation
  17621. point and pushing it about in a series of random steps. However
  17622. warps push the point in very well-defined, non-random, geometric
  17623. ways. The warp statement also overcomes some limitations of
  17624. traditional turbulence and transformations by giving the user
  17625. more control over the order in which turbulence, transformation
  17626. and warp modifiers are applied to the pattern.
  17627.  
  17628. Currently there are three types of warps but the syntax was
  17629. designed to allow future expansion. The first two, the repeat
  17630. warp and the black_hole warp are new features for POV-Ray that
  17631. modify the pattern in geometric ways. The other warp provides an
  17632. alternative way to specify turbulence.
  17633.  
  17634. The syntax for using a warp statement is:
  17635.  
  17636. WARP:
  17637.   warp { WARP_ITEM }
  17638. WARP_ITEM:
  17639.   repeat <Directiont>  [REPEAT_ITEMS...]   |
  17640.   black_hole <Location>, Radius [BLACK_HOLE_ITEMS...]   |
  17641.   turbulence <Amount> [TURB_ITEMS...]
  17642. REPEAT_ITEMS:
  17643.   offset <Amount>   |   flip <Axis>
  17644. BLACK_HOLE_ITEMS:
  17645.   strength Strength   |   falloff Amount   |   inverse   |
  17646.   type Type   |
  17647.   repeat <Repeat>   |   turbulence <Amount>
  17648. TURB_ITEMS:
  17649.   octaves Count   |   omega Amount   |   lambda Amount
  17650. You may have as many separate warp statements as you like in each
  17651. pattern. The placement of warp statements relative to other
  17652. modifiers such as color_map or turbulence is not important.
  17653. However placement of warp statements relative to each other and
  17654. to transformations is significant. Multiple warps and
  17655. transformations are evaluated in the order in which you specify
  17656. them. For example if you translate, then warp or warp, then
  17657. translate, the results can be different.
  17658.  
  17659.  
  17660. 4.7.8.8.1 Black Hole Warp
  17661. A black_hole warp is so named because of its similarity to real
  17662. black holes. Just like the real thing, you cannot actually see a
  17663. black hole. The only way to detect its presence is by the effect
  17664. it has on things that surround it.
  17665.  
  17666. Take, for example, a wood grain. Using POV-Ray's normal
  17667. turbulence and other texture modifier functions, you can get a
  17668. nice, random appearance to the grain. But in its randomness it is
  17669. regular - it is regularly random! Adding a black hole allows you
  17670. to create a localized disturbance in a wood grain in either one
  17671. or multiple locations. The black hole can have the effect of
  17672. either sucking the surrounding texture into itself (like the real
  17673. thing) or pushing it away. In the latter case, applied to a wood
  17674. grain, it would look to the viewer as if there were a knothole in
  17675. the wood. In this text we use a wood grain regularly as an
  17676. example, because it is ideally suitable to explaining black
  17677. holes. However, black holes may in fact be used with any texture
  17678. or pattern.  The effect that the black hole has on the texture
  17679. can be specified.  By default, it sucks with the strength
  17680. calculated exponentially (inverse-square). You can change this if
  17681. you like.
  17682.  
  17683. Black holes may be used anywhere a warp is permitted. The syntax
  17684. is:
  17685.  
  17686. BLACK_HOLE_WARP:
  17687.   warp {black_hole <Location>, Radius [BLACK_HOLE_ITEMS...] }
  17688. BLACK_HOLE_ITEMS:
  17689.   strength Strength   |   falloff Amount   |   inverse   |
  17690.   type Type   |
  17691.   repeat <Repeat>   |   turbulence <Amount>
  17692. The minimal requirement is the black_hole keyword followed by a
  17693. vector <Location> followed by a comma and a float Radius.  Black
  17694. holes effect all points within the spherical region around the
  17695. location and within the radius.  This is optionally followed by
  17696. any number of other keywords which control how the texture is
  17697. warped.
  17698.  
  17699. The falloff keyword may be used with a float value to specify the
  17700. power by which the effect of the black hole falls off. The
  17701. default is two. The force of the black hole at any given point,
  17702. before applying the strength modifier, is as follows.
  17703.  
  17704. First, convert the distance from the point to the center to a
  17705. proportion (0 to 1) that the point is from the edge of the black
  17706. hole. A point on the perimeter of the black hole will be 0.0; a
  17707. point at the center will be 1.0; a point exactly halfway will be
  17708. 0.5, and so forth.  Mentally you can consider this to be a
  17709. closeness factor. A closeness of 1.0 is as close as you can get
  17710. to the center (i.e. at the center), a closeness of 0.0 is as far
  17711. away as you can get from the center and still be inside the black
  17712. hole and a closeness of 0.5 means the point is exactly halfway
  17713. between the two.
  17714.  
  17715. Call this value c. Raise c to the power specified in falloff. By
  17716. default Falloff is 2, so this is c2 or c squared. The resulting
  17717. value is the force of the black hole at that exact location and
  17718. is used, after applying the strength scaling factor as described
  17719. below, to determine how much the point is perturbed in space. For
  17720. example, if c is 0.5 the force is 0.52 or 0.25. If c is 0.25 the
  17721. force is 0.125. But if c is exactly 1.0 the force is 1.0.  Recall
  17722. that as c gets smaller the point is farther from the center of
  17723. the black hole. Using the default power of 2, you can see that as
  17724. c reduces, the force reduces exponentially in an inverse-square
  17725. relationship. Put in plain English, it means that the force is
  17726. much stronger (by a power of two) towards the center than it is
  17727. at the outside.
  17728.  
  17729. By increasing falloff, you can increase the magnitude of the
  17730. falloff. A large value will mean points towards the perimeter
  17731. will hardly be affected at all and points towards the center will
  17732. be affected strongly.  A value of 1.0 for falloff will mean that
  17733. the effect is linear. A point that is exactly halfway to the
  17734. center of the black hole will be affected by a force of exactly
  17735. 0.5.  A value of falloff of less than one but greater than zero
  17736. means that as you get closer to the outside, the force increases
  17737. rather than decreases. This can have some uses but there is a
  17738. side effect.  Recall that the effect of a black hole ceases
  17739. outside its perimeter.  This means that points just within the
  17740. perimeter will be affected strongly and those just outside not at
  17741. all. This would lead to a visible border, shaped as a sphere.  A
  17742. value for falloff of 0 would mean that the force would be 1.0 for
  17743. all points within the black hole, since any number larger 0
  17744. raised to the power of 0 is 1.0.
  17745.  
  17746. The strength keyword may be specified with a float value to give
  17747. you a bit more control over how much a point is perturbed by the
  17748. black hole. Basically, the force of the black hole (as determined
  17749. above) is multiplied by the value of strength, which defaults to
  17750. 1.0. If you set strength to 0.5, for example, all points within
  17751. the black hole will be moved by only half as much as they would
  17752. have been. If you set it to 2.0 they will be moved twice as much.
  17753.  
  17754. There is a rider to the latter example, though - the movement is
  17755. clipped to a maximum of the original distance from the center.
  17756. That is to say, a point that is 0.75 units from the center may
  17757. only be moved by a maximum of 0.75 units either towards the
  17758. center or away from it, regardless of the value of strength. The
  17759. result of this clipping is that you will have an exclusion area
  17760. near the center of the black hole where all points whose final
  17761. force value exceeded or equaled 1.0 were moved by a fixed amount.
  17762.  
  17763. If the inverted keyword is specified then points pushed away from
  17764. the center instead of being pulled in.
  17765.  
  17766. The repeat keyword followed by a vector, allows you to simulate
  17767. the effect of many black holes without having to explicitly
  17768. declare them. Repeat is a vector that tells POV-Ray to use this
  17769. black hole at multiple locations.  Using repeat logically divides
  17770. your scene up into cubes, the first being located at <0,0,0> and
  17771. going to <Repeat>. Suppose your repeat vector was <1,5,2>. The
  17772. first cube would be from <0,0,0> to < 1,5,2>. This cube repeats,
  17773. so there would be one at < -1,-5,-2>, <1,5,2>, <2,10,4> and so
  17774. forth in all directions, ad infinitum.
  17775.  
  17776. When you use repeat, the center of the black hole does not
  17777. specify an absolute location in your scene but an offset into
  17778. each block. It is only possible to use positive offsets. Negative
  17779. values will produce undefined results.
  17780.  
  17781. Suppose your center was <0.5,1,0.25> and the repeat vector is
  17782. <2,2,2>. This gives us a block at < 0,0,0> and <2,2,2>, etc. The
  17783. centers of the black hole's for these blocks would be <0,0,0> + <
  17784. 0.5,1.0,0.25>, i. e. <0.5,1.0,0.25>, and < 2,2,2> +
  17785. <0.5,1.0,0.25>, i. e. < 2,5,3.0,2.25>.
  17786.  
  17787. Due to the way repeats are calculated internally, there is a
  17788. restriction on the values you specify for the repeat vector.
  17789. Basically, each black hole must be totally enclosed within each
  17790. block (or cube), with no part crossing into a neighboring one.
  17791. This means that, for each of the x, y and z dimensions, the
  17792. offset of the center may not be less than the radius, and the
  17793. repeat value for that dimension must be >=the center plus the
  17794. radius since any other values would allow the black hole to cross
  17795. a boundary. Put another way, for each of x, y and z
  17796.  
  17797. Radius <= Offset or Center <= Repeat - Radius.
  17798. If the repeat vector in any dimension is too small to fit this
  17799. criteria, it will be increased and a warning message issued. If
  17800. the center is less than the radius it will also be moved but no
  17801. message will be issued.
  17802.  
  17803. Note that none of the above should be read to mean that you can't
  17804. overlap black holes. You most certainly can and in fact this can
  17805. produce some most useful effects. The restriction only applies to
  17806. elements of the same black hole which is repeating. You can
  17807. declare a second black hole that also repeats and its elements
  17808. can quite happily overlap the first and causing the appropriate
  17809. interactions.  It is legal for the repeat value for any dimension
  17810. to be 0, meaning that POV-Ray will not repeat the black hole in
  17811. that direction.
  17812.  
  17813. The turbulence can only be used in a black hole with repeat. It
  17814. allows an element of randomness to be inserted into the way the
  17815. black holes repeat, to cause a more natural look. A good example
  17816. would be an array of knotholes in wood - it would look rather
  17817. artificial if each knothole were an exact distance from the
  17818. previous.
  17819.  
  17820. The turbulence vector is a measurement that is added to each
  17821. individual back hole in an array, after each axis of the vector
  17822. is multiplied by a different random amount ranging from 0 to 1.
  17823. The resulting actual position of the black hole's center for that
  17824. particular repeat element is random (but consistent, so renders
  17825. will be repeatable) and somewhere within the above co-ordinates.
  17826. There is a rider on the use of turbulence, which basically is the
  17827. same as that of the repeat vector. You can't specify a value
  17828. which would cause a black hole to potentially cross outside of
  17829. its particular block.
  17830.  
  17831. In summary: For each of x, y and z the offset of the center must
  17832. be >=radius and the value of the repeat must be >= center +
  17833. radius + turbulence. The exception being that repeat may be 0 for
  17834. any dimension, which means do not repeat in that direction.
  17835.  
  17836. Some examples are given by
  17837.  
  17838.   warp
  17839.   {
  17840.     black_hole <0, 0, 0>, 0.5
  17841.   }
  17842.   warp
  17843.   {
  17844.     black_hole <0.15, 0.125, 0>, 0.5
  17845.     falloff 7
  17846.     strength 1.0
  17847.     repeat <1.25, 1.25, 0>
  17848.     turbulence <0.25, 0.25, 0>
  17849.     inverse
  17850.   }
  17851.   warp
  17852.   {
  17853.     black_hole <0, 0, 0>, 1.0
  17854.     falloff 2
  17855.     strength 2
  17856.     inverse
  17857.   }
  17858.  
  17859. 4.7.8.8.2 Repeat Warp
  17860. The repeat warp causes a section of the pattern to be repeated
  17861. over and over. It takes a slice out of the pattern and makes
  17862. multiple copies of it side-by-side. The warp has many uses but
  17863. was originally designed to make it easy to model wood veneer
  17864. textures. Veneer is made by taking very thin slices from a log
  17865. and placing them side-by-side on some other backing material. You
  17866. see side-by-side nearly identical ring patterns but each will be
  17867. a slice perhaps 1/32th of an inch deeper.
  17868.  
  17869. The syntax for a repeat warp is
  17870.  
  17871. REPEAT_WARP:
  17872.   warp { repeat <Directiont>  [REPEAT_ITEMS...] }
  17873. REPEAT_ITEMS:
  17874.   offset <Amount>   |   flip <Axis>
  17875. The repeat vector specifies the direction in which the pattern
  17876. repeats and the width of the repeated area. This vector must lie
  17877. entirely along an axis. In other words, two of its three
  17878. components must be 0. For example
  17879.  
  17880.   pigment {
  17881.     wood
  17882.     warp {repeat 2*x}
  17883.   }
  17884. which means that from x=0 to x=2 you get whatever the pattern
  17885. usually is. But from x=2 to x=4 you get the same thing exactly
  17886. shifted two units over in the x-direction. To evaluate it you
  17887. simply take the x-coordinate modulo 2. Unfortunately you get
  17888. exact duplicates which isn't very realistic. The optional offset
  17889. vector tells how much to translate the pattern each time it
  17890. repeats. For example
  17891.  
  17892.   pigment {
  17893.     wood
  17894.     warp {repeat x*2  offset z*0.05}
  17895.   }
  17896. means that we slice the first copy from x=0 to x=2 at z=0 but at
  17897. x=2 to x=4 we offset to z=0.05. In the 4 to 6 interval we slice
  17898. at z=0.10. At the n-th copy we slice at 0.05 n z. Thus each copy
  17899. is slightly different. There are no restrictions on the offset
  17900. vector.
  17901.  
  17902. Finally the flip vector causes the pattern to be flipped or
  17903. mirrored every other copy of the pattern. The first copy of the
  17904. pattern in the positive direction from the axis is not flipped.
  17905. The next farther is, the next is not, etc. The flip vector is a
  17906. three component x, y, z vector but each component is treated as a
  17907. boolean value that tells if you should or should not flip along a
  17908. given axis. For example
  17909.  
  17910.   pigment {
  17911.     wood
  17912.     warp {repeat 2*x  flip <1,1,0>}
  17913.   }
  17914. means that every other copy of the pattern will be mirrored about
  17915. the x- and y- axis but not the z-axis. A non-zero value means
  17916. flip and zero means do not flip about that axis. The magnitude of
  17917. the values in the flip vector doesn't matter.
  17918.  
  17919.  
  17920. 4.7.8.8.3 Turbulence Warp
  17921. The POV-Ray language contains an ambiguity and limitation on the
  17922. way you specify turbulence and transformations such as translate,
  17923. rotate, scale, matrix, and transform transforms. Usually the
  17924. turbulence is done first.  Then all translate, rotate, scale,
  17925. matrix, and transform operations are always done after turbulence
  17926. regardless of the order in which you specify them. For example
  17927. this
  17928.  
  17929.  pigment {
  17930.    wood
  17931.    scale .5
  17932.    turbulence .2
  17933.  }
  17934. works exactly the same as
  17935.  
  17936.  pigment {
  17937.    wood
  17938.    turbulence .2
  17939.    scale .5
  17940.  }
  17941. The turbulence is always first. A better example of this
  17942. limitation is with uneven turbulence and rotations.
  17943.  
  17944.   pigment {
  17945.     wood
  17946.     turbulence 0.5*y
  17947.     rotate z*60
  17948.   }
  17949.   // as compared to
  17950.   pigment {
  17951.    wood
  17952.    rotate z*60
  17953.    turbulence 0.5*y
  17954.   }
  17955. The results will be the same either way even though you'd think
  17956. it should look different.
  17957.  
  17958. We cannot change this basic behavior in POV-Ray now because lots
  17959. of scenes would potentially render differently if suddenly the
  17960. order transformation vs. turbulence suddenly mattered when in the
  17961. past, it didn't.
  17962.  
  17963. However, by specifying our turbulence inside warp statement you
  17964. tell POV-Ray that the order in which turbulence, transformations
  17965. and other warps are applied is significant. Here's an example of
  17966. a turbulence warp.
  17967.  
  17968.   warp { turbulence <0,1,1> octaves 3 lambda 1.5 omega 0.3 }
  17969. The significance is that this
  17970.  
  17971.  pigment {
  17972.    wood
  17973.    translate <1,2,3> rotate x*45 scale 2
  17974.    warp { turbulence <0,1,1> octaves 3 lambda 1.5 omega 0.3 }
  17975.  }
  17976. produces different results than this...
  17977.  
  17978.  pigment {
  17979.    wood
  17980.    warp { turbulence <0,1,1> octaves 3 lambda 1.5 omega 0.3 }
  17981.    translate <1,2,3> rotate x*45 scale 2
  17982.  }
  17983. You may specify turbulence without using a warp statement.
  17984. However you cannot control the order in which they are evaluated
  17985. unless you put them in a warp.
  17986.  
  17987. The evaluation rules are as follows:
  17988.  
  17989.  
  17990.   1)   First any turbulence not inside a warp statement is
  17991.   applied regardless of the order in which it appears relative
  17992.   to warps or transformations.
  17993.   2)   Next each warp statement, translate, rotate, scale or
  17994.   matrix one-by-one, is applied in the order the user specifies.
  17995.   If you want turbulence done in a specific order, you simply
  17996.   specify it inside a warp in the proper place.
  17997.  
  17998. 4.7.8.9   Bitmap Modifiers
  17999. A bitmap modifier is a modifier used inside an image_map,
  18000. bump_map or material_map to specify how the 2-D bitmap is to be
  18001. applied to the 3-D surface. Several bitmap modifiers apply to
  18002. specific kinds of maps and they are covered in the appropriate
  18003. sections. The bitmap modifiers discussed in the following
  18004. sections are applicable to all three types of bitmaps.
  18005.  
  18006.  
  18007. 4.7.8.9.1 The once Option
  18008. Normally there are an infinite number of repeating image maps,
  18009. bump maps or material maps created over every unit square of the
  18010. x-y-plane like tiles. By adding the once keyword after a file
  18011. name you can eliminate all other copies of the map except the one
  18012. at (0,0) to (1,1). In image maps, areas outside this unit square
  18013. are treated as fully transparent. In bump maps, areas outside
  18014. this unit square are left flat with no normal modification.  In
  18015. material maps, areas outside this unit square are textured with
  18016. the first texture of the texture list.
  18017.  
  18018. For example:
  18019.  
  18020.   image_map {
  18021.     gif "mypic.gif"
  18022.     once
  18023.   }
  18024.  
  18025. 4.7.8.9.2 The map_type Option
  18026. The default projection of the image onto the x-y-plane is called
  18027. a planar map type. This option may be changed by adding the
  18028. map_type keyword followed by an integer number specifying the way
  18029. to wrap the image around the object.
  18030.  
  18031. A map_type 0 gives the default planar mapping already described.
  18032.  
  18033. A map_type 1 gives a spherical mapping. It assumes that the
  18034. object is a sphere of any size sitting at the origin. The y-axis
  18035. is the north/south pole of the spherical mapping. The top and
  18036. bottom edges of the image just touch the pole regardless of any
  18037. scaling. The left edge of the image begins at the positive x-axis
  18038. and wraps the image around the sphere from west to east in a -y-
  18039. rotation. The image covers the sphere exactly once. The once
  18040. keyword has no meaning for this mapping type.
  18041.  
  18042. With map_type 2 you get a cylindrical mapping. It assumes that a
  18043. cylinder of any diameter lies along the y-axis. The image wraps
  18044. around the cylinder just like the spherical map but the image
  18045. remains one unit tall from y=0 to y=1. This band of color is
  18046. repeated at all heights unless the once keyword is applied.
  18047.  
  18048. Finally map_type 5 is a torus or donut shaped mapping. It assumes
  18049. that a torus of major radius one sits at the origin in the x-z-
  18050. plane. The image is wrapped around similar to spherical or
  18051. cylindrical maps. However the top and bottom edges of the map
  18052. wrap over and under the torus where they meet each other on the
  18053. inner rim.
  18054.  
  18055. Types 3 and 4 are still under development.
  18056.  
  18057. Note that the map_type option may also be applied to bump_map and
  18058. material_map statements.
  18059.  
  18060. For example:
  18061.  
  18062.   sphere{<0,0,0>,1
  18063.     pigment{
  18064.       image_map {
  18065.         gif "world.gif"
  18066.         map_type 1
  18067.       }
  18068.     }
  18069.   }
  18070.  
  18071. 4.7.8.9.3 The interpolate Option
  18072. Adding the interpolate keyword can smooth the jagged look of a
  18073. bitmap. When POV-Ray asks an image map color or a bump amount for
  18074. a bump map, it often asks for a point that is not directly on top
  18075. of one pixel but sort of between several differently colored
  18076. pixels. Interpolations returns an in-between value so that the
  18077. steps between the pixels in the map will look smoother.
  18078.  
  18079. Although interpolate is legal in material maps, the color index
  18080. is interpolated before the texture is chosen. It does not
  18081. interpolate the final color as you might hope it would. In
  18082. general, interpolation of material maps serves no useful purpose
  18083. but this may be fixed in future versions.
  18084.  
  18085. There are currently two types of interpolation:  interpolate 2
  18086. gives bilinear interpolation while interpolate 4 gives normalized
  18087. distance.  For example:
  18088.  
  18089.   image_map {
  18090.     gif "mypic.gif"
  18091.     interpolate 2
  18092.   }
  18093. Default is no interpolation. Normalized distance is the slightly
  18094. faster of the two, bilinear does a better job of picking the
  18095. between color. Normally bilinear is used.
  18096.  
  18097. If your map looks jaggy, try using interpolation instead of going
  18098. to a higher resolution image. The results can be very good.
  18099.  
  18100.  
  18101. 4.8  Media
  18102. The media statement is used to specify particulate matter
  18103. suspended in a medium such air or water.  It can be used to
  18104. specify smoke, haze, fog, gas, fire, dust etc.  Previous versions
  18105. of POV-Ray had two incompatible systems for generating such
  18106. effects.  One was halo for effects enclosed in a transparent or
  18107. semi-transparent object.  The other was atmosphere for effects
  18108. that  permeated the entire scene.  This duplication of systems
  18109. was complex and unnecessary.  Both halo and atmosphere have been
  18110. eliminated.  See "Why are Interior and Media Necessary?" for
  18111. further details on this change.  See "Object Media" for details
  18112. on how to use media with objects.  See "Atmospheric Media" for
  18113. details on using media for atmospheric effects outside of
  18114. objects.  This section and the sub-sections which follow explains
  18115. the details of the various media options which are useful for
  18116. either object media or atmospheric media.
  18117.  
  18118. Media works by sampling the density of particles at some
  18119. specified number of points along the ray's path.  Sub-samples are
  18120. also taken until the results reach a specified confidence level.
  18121. When used in an object's interior statement, sampling only occurs
  18122. inside the object.  When used for atmospheric media, the samples
  18123. run from the camera location until the ray strikes an object.
  18124. Therefore for localized effects, it is best to use an enclosing
  18125. object even though the density pattern might only produce results
  18126. in a small area whether the media was enclosed or not.
  18127.  
  18128. The complete syntax for a media statement is as follows:
  18129.  
  18130. MEDIA:
  18131.   media { [MEDIA_IDENTIFIER] [MEDIA_ITEMS...] }
  18132. MEDIA_ITEMS:
  18133.   intervals Number   |   samples Min, Max   |
  18134.   confidence Value   |   variance Value   |   ratio Value   |
  18135.   absorption  COLOR   |   emission COLOR   |
  18136.   scattering { Type, COLOR  [ eccentricity Value ] [ extinction
  18137.   Value ] }   |
  18138.   density { [DENSITY_IDENTIFIER] [PATTERN_TYPE]
  18139.   [DENSITY_MODIFIER...]  }   |
  18140.   TRANSFORMATIONS
  18141. DENSITY_MODIFIER:
  18142.   PATTERN_MODIFIER   |   DENSITY_LIST   |   COLOR_LIST   |
  18143.   color_map{ COLOR_MAP_BODY }   |   colour_map{ COLOR_MAP_BODY }
  18144.   |
  18145.   density_map{ DENSITY_MAP_BODY }
  18146. If a media identifier is specified, it must be the first item.
  18147. All other media items may be specified in any order.  All are
  18148. optional.  You may have multiple density statements in a single
  18149. media statement.  See "Multiple Density vs. Multiple Media" for
  18150. details.  Transformations apply only the density statements which
  18151. have been already specified.  Any density after a transformation
  18152. is not affected.  If the media has no density statements and none
  18153. was specified in any media identifier, then the transformation
  18154. has no effect.  All other media items except for density and
  18155. transformations override default values or any previously set
  18156. values for this media statement.
  18157.  
  18158. Note that some media effects depend upon light sources.  However
  18159. the participation of a light source depends upon the
  18160. media_interaction and media_attenuation keywords.  See
  18161. "Atmospheric Media Interaction" and "Atmospheric Attenuation" for
  18162. details.
  18163.  
  18164. Note a strange design side-effect was discovered during testing
  18165. and it was too difficult to fix.  If the enclosing object uses
  18166. transmit rather than filter for transparency, then the media
  18167. casts no shadows.  For example:
  18168.  
  18169.  object{MyObject pigment{rgbt 1.0} interior{media{MyMedia}}} //no
  18170. shadows
  18171.  object{MyObject pigment{rgbf 1.0} interior{media{MyMedia}}}
  18172. //shadows
  18173.  
  18174. 4.8.1     Media Types
  18175. There are three types of particle interaction in media:
  18176. absorbing, emitting, and scattering.  All three activities may
  18177. occur in a single media.  Each of these three specifications
  18178. requires a color.  Only the red, green, and blue components of
  18179. the color are used.  The filter and transmit values are ignored.
  18180. For this reason it is permissible to use one float value to
  18181. specify an intensity of white color.  For example the following
  18182. two lines are legal and produce the same results:
  18183.  
  18184.   emission 0.75
  18185.   emission rgb<0.75,0.75,0.75>
  18186.  
  18187. 4.8.1.1   Absorption
  18188. The absorption keyword specifies a color of light which is
  18189. absorbed when looking through the media.  For example absorption
  18190. rgb<0,1,0> blocks the green light but permits red and blue to get
  18191. through.  Therefore a white object behind the media will appear
  18192. magenta.
  18193.  
  18194. The default value is rgb<0,0,0> which means no light is absorbed
  18195. -- all light passes through normally.
  18196.  
  18197.  
  18198. 4.8.1.2   Emission
  18199. The emission keyword specifies a color of the light emitted from
  18200. the particles.  Although we say they "emit" light, this only
  18201. means that they are visible without any illumination shining on
  18202. them.  They to not really emit light that is cast on to nearby
  18203. objects.  This is similar to an object with high ambient values.
  18204. The default value is rgb<0,0,0> which means no light is emitted.
  18205.  
  18206.  
  18207. 4.8.1.3   Scattering
  18208. The syntax of a scattering statement is:
  18209.  
  18210. SCATTERING:
  18211.   scattering { Type, COLOR  [ eccentricity Value ] [ extinction
  18212.   Value ] }
  18213. The first float value specifies the type of scattering.  This is
  18214. followed by the color of the scattered light.  The default value
  18215. if no scattering statement is given is rgb<0,0,0> which means no
  18216. scattering occurs.
  18217.  
  18218. The scattering effect is only visible when light is shining on
  18219. the media from a light source.  This is similar to difuse
  18220. reflection off of an object.  In addition to reflecting light, a
  18221. scattering media also absorbs light like an absorption media.
  18222. The balance between how much absorption occurs for a given amount
  18223. of scattering is controlled by the optional extinction keyword
  18224. and a single float value.  The default value of 1.0 gives an
  18225. extinction effect that matches the scattering.  Values such as
  18226. extinction 0.25 give 25% the normal amount.  Using extinction 0.0
  18227. turns it off completely.  Any value other than the 1.0 default is
  18228. contrary to the real physical model but decreasing extinction can
  18229. give you more artistic flexibility.
  18230.  
  18231. The integer value Type specifies one of five different scattering
  18232. phase functions representing the different models: isotropic, Mie
  18233. (haze and murky atmosphere), Rayleigh, and Henyey-Greenstein.
  18234.  
  18235. Type 1, isotropic scattering is the simplest form of scattering
  18236. because it is independent of direction. The amount of light
  18237. scattered by particles in the atmosphere does not depend on the
  18238. angle between the viewing direction and the incoming light.
  18239.  
  18240. Types 2 and 3 are Mie haze and Mie murky scattering which are
  18241. used for relatively small particles such as minuscule water
  18242. droplets of fog, cloud particles, and particles responsible for
  18243. the polluted sky. In this model the scattering is extremely
  18244. directional in the forward direction i.e. the amount of scattered
  18245. light is largest when the incident light is anti-parallel to the
  18246. viewing direction (the light goes directly to the viewer). It is
  18247. smallest when the incident light is parallel to the viewing
  18248. direction. The haze and murky atmosphere models differ in their
  18249. scattering characteristics. The murky model is much more
  18250. directional than the haze model.
  18251.  
  18252.                                 
  18253.                The Mie "haze" scattering function.
  18254.                                 
  18255.               The Mie "murky" scattering function.
  18256. Type 3 Rayleigh scattering models the scattering for extremely
  18257. small particles such as molecules of the air. The amount of
  18258. scattered light depends on the incident light angle. It is
  18259. largest when the incident light is parallel or anti-parallel to
  18260. the viewing direction and smallest when the incident light is
  18261. perpendicular to the viewing direction. You should note that the
  18262. Rayleigh model used in POV-Ray does not take the dependency of
  18263. scattering on the wavelength into account.
  18264.  
  18265.                                 
  18266.                 The Rayleigh scattering function.
  18267. Type 5 is the Henyey-Greenstein scattering model.  It is based on
  18268. an analytical function and can be used to model a large variety
  18269. of different scattering types. The function models an ellipse
  18270. with a given eccentricity e. This eccentricity is specified by
  18271. the optional keyword eccentricity which is only used for
  18272. scattering type five. The default eccentricity value of zero
  18273. defines isotropic scattering while positive values lead to
  18274. scattering in the direction of the light and negative values lead
  18275. to scattering in the opposite direction of the light. Larger
  18276. values of e (or smaller values in the negative case) increase the
  18277. directional property of the scattering.
  18278.  
  18279.                                 
  18280.      The Heyney-Greenstein scattering function for different
  18281.                       eccentricity values.
  18282.  
  18283. 4.8.2     Sampling Parameters
  18284. Media effects are calculated by sampling the media along the path
  18285. of the ray.  It uses a method called Monte Carlo integration.
  18286. The intervals keyword may be used to specify the integer number
  18287. of intervals used to sample the ray.  The default number of
  18288. intervals is 10.  For object media the intervals are spread
  18289. between the entry and exit points as the ray passes through the
  18290. container object.  For atmospheric media, the intervals span
  18291. entire length of the ray from its start until it hits an object.
  18292.  
  18293. For media types which interact with spotlights or cylinder
  18294. lights, the intervals which are not illuminated by these light
  18295. types are weighted differently than the illuminated intervals
  18296. when distributing samples.  The ratio keyword distributes
  18297. intervals differently between lit and unlit areas.  The default
  18298. value of ratio 0.9 means that lit intervals get more samples than
  18299. unlit intervals.  Note that the total number of intervals must
  18300. exceed the number of illuminated intervals.  If a ray passes in
  18301. and out of 8 spotlights but you've only specified 5 intervals
  18302. then an error occurs.
  18303.  
  18304. The samples Min, Max keyword specifies the minimum and maximum
  18305. number of samples taken per interval.  The default values are
  18306. samples 1,1.
  18307.  
  18308. As each interval is sampled, the variance is computed.  If the
  18309. variance is below a threshold value, then no more samples are
  18310. needed.  The variance and confidence keywords specify the
  18311. permitted variance allowed and the confidence that you are within
  18312. that variance.  The exact calculations are quite complex and
  18313. involve chi-squared tests and other statistical principles too
  18314. messy to describe here.  The default values are varience 1.0/128
  18315. and confidence 0.9.  For slower more accurate results, decrease
  18316. the variance and increase the confidence.  Note however that the
  18317. maximum number of samples limits the calculations even if the
  18318. proper variance and confidence are never reached.
  18319.  
  18320.  
  18321. 4.8.3     Density
  18322. Particles of media are normally distributed in constant density
  18323. throughout the media.  However the density statement allows you
  18324. to vary the density across space using any of POV-Ray's pattern
  18325. functions such as those used in textures.  If no density
  18326. statement is given then the density remains a constant value of
  18327. 1.0 throughout the media.  More than one density may be specified
  18328. per media statement.  See "Multiple Density vs. Multiple Media".
  18329.  
  18330. The syntax for density is:
  18331.  
  18332. DENSITY:
  18333.   density { [DENSITY_IDENTIFIER] [DENSITY_TYPE]
  18334. [DENSITY_MODIFIER...]  }
  18335. DENSITY_TYPE:
  18336.   PATTERN_TYPE   |   COLOR
  18337. DENSITY_MODIFIER:
  18338.   PATTERN_MODIFIER   |   DENSITY_LIST   |
  18339.   color_map{ COLOR_MAP_BODY }   |   colour_map{ COLOR_MAP_BODY }
  18340.   |
  18341.   density_map{ DENSITY_MAP_BODY }
  18342. The density statement may begin with an optional density
  18343. identifier.  All subsequent values modify the defaults or the
  18344. values in the identifier.  The next item is a pattern type.  This
  18345. is any one of POV-Ray's pattern functions such as bozo, wood,
  18346. gradient, waves, etc.  Of particular usefulness are the
  18347. spherical, planar, cylindrical, and boxed patterns which were
  18348. previously available only for use with our discontinued halo
  18349. feature.  All patterns return a value from 0.0 to 1.0.  This
  18350. value is interpreted as the density of the media at that
  18351. particular point.  See "Patterns" for details on particular
  18352. pattern types.   Although a solid COLOR pattern is legal, in
  18353. general it is used only when the density statement is inside a
  18354. density_map.
  18355.  
  18356.  
  18357. 4.8.3.1   General Density Modifiers
  18358. A density statement may be modified by any of the general pattern
  18359. modifiers such as transformations, turbulence and warp.  See
  18360. "Pattern Modifiers" for details.  In addition there are several
  18361. density-specific modifiers which can be used.
  18362.  
  18363.  
  18364. 4.8.3.2   Density with color_map
  18365. Typically a media uses just one constant color throughout.  Even
  18366. if you vary the density, it is usually just one color which is
  18367. specified by the absorption, emission, or scattering keywords.
  18368. However when using emission to simulate fire or explosions, the
  18369. center of the flame (high density area) is typically brighter and
  18370. white or yellow.  The outer edge of the flame (less density)
  18371. fades to orange, red, or in some cases deep blue.  To model the
  18372. density-dependent change in color which is visible, you may
  18373. specify a color_map.  The pattern function returns a value from
  18374. 0.0 to 1.0 and the value is passed to the color map to compute
  18375. what color or blend of colors is used.  See "Color Maps" for
  18376. details on how pattern values work with color_map. This resulting
  18377. color is multiplied by the absorption, emission and scattering
  18378. color.  Currently there is no way to specify different color maps
  18379. for each media type within the same media statement.
  18380.  
  18381. Consider this example:
  18382.  
  18383.   media{
  18384.     emission 0.75
  18385.     scattering {1, 0.5}
  18386.     density { spherical
  18387.       color_map{
  18388.         [0.0 rgb <0,0,0.5>]
  18389.         [0.5 rgb <0.8, 0.8, 0.4>]
  18390.         [1.0 rgb <1,1,1>]
  18391.       }
  18392.     }
  18393.   }
  18394. The color map ranges from white at density 1.0 to bright yellow
  18395. at density 0.5 to deep blue at density 0.  Assume we sample a
  18396. point at density 0.5.  The emission is 0.75*<0.8,0.8,0.4> or
  18397. <0.6,0.6,0.3>.  Similarly the scattering color is
  18398. 0.5*<0.8,0.8,0.4> or <0.4,0.4,0.2>.
  18399.  
  18400. For block pattern types checker, hexagon, and brick you may
  18401. specify a color list such as this:
  18402.  
  18403.   density{checker rgb<1,0,0>, rgb<0,0,0>}
  18404. See "Color List Pigments" which describes how pigment uses a
  18405. color list.  The same principles apply when using them with
  18406. density.
  18407.  
  18408.  
  18409. 4.8.3.3   Density Maps and Density Lists
  18410. In addition to specifying blended colors with a color map you may
  18411. create a blend of densities using a density_map. The syntax for a
  18412. density map is identical to a color map except you specify a
  18413. density in each map entry (and not a color).
  18414.  
  18415. The syntax for density_map is as follows:
  18416.  
  18417. DENSITY_MAP:
  18418.   density_map{ DENSITY_MAP_BODY }
  18419. DENSITY_MAP_BODY:
  18420.   DENSITY_MAP_IDENTIFIER   |   DENSITY_MAP_ENTRY...
  18421. DENSITY_MAP_ENTRY:
  18422.   [ Value  DENSITY_BODY ]
  18423. Where Value is a float value between 0.0 and 1.0 inclusive and
  18424. each DENSITY_BODY is anything which can be inside a density{...}
  18425. statement.  The density keyword and {} braces need not be
  18426. specified.
  18427.  
  18428. Note that the [] brackets are part of the actual
  18429. DENSITY_MAP_ENTRY. They are not notational symbols denoting
  18430. optional parts. The brackets surround each entry in the density
  18431. map. There may be from 2 to 256 entries in the map.
  18432.  
  18433. Density maps may be nested to any level of complexity you desire.
  18434. The densities in a map may have color maps or density maps or any
  18435. type of density you want.
  18436.  
  18437. Entire densities may also be used with the block patterns such as
  18438. checker, hexagon and brick. For example...
  18439.  
  18440.   density {
  18441.     checker
  18442.     density { Flame scale .8 }
  18443.     density { Fire scale .5 }
  18444.   }
  18445. Note that in the case of block patterns the density wrapping is
  18446. required around the density information.
  18447.  
  18448. A density map is also used with the average density type. See
  18449. "Average" for details.
  18450.  
  18451. You may declare and use density map identifiers but the only way
  18452. to declare a density block pattern list is to declare a density
  18453. identifier for the entire density.
  18454.  
  18455.  
  18456. 4.8.3.4   Multiple Density vs. Multiple Media
  18457. It is possible to have more than one media specified per object
  18458. and it is legal to have more than one density per media.  The
  18459. effects are quite different.  Consider this example:
  18460.  
  18461.   object{MyObject
  18462.     pigment{rgbf 1}
  18463.     interior{
  18464.       media{
  18465.         density{Some_Density}
  18466.         density{Another_Density}
  18467.       }
  18468.     }
  18469.   }
  18470. As the media is sampled, calculations are performed for each
  18471. density pattern at each sample point.  The resulting samples are
  18472. multiplied together.  Suppose one density returned rgb<.8,.8,.4>
  18473. and the other returned rgb<.25,.25,0>.  The resulting color is
  18474. rgb<.2,.2,0>.  Note that in areas where one density returns zero,
  18475. it will wipe out the other density.  The end result is that only
  18476. density areas which overlap will be visible.  This is similar to
  18477. a CSG intersection operation.  Now consider
  18478.  
  18479.   object{MyObject
  18480.     pigment{rgbf 1}
  18481.     interior{
  18482.       media{
  18483.         density{Some_Density}
  18484.       }
  18485.       media{
  18486.         density{Another_Density}
  18487.       }
  18488.     }
  18489.   }
  18490. In this case each media is computed independently.  The resulting
  18491. colors are added together.  Suppose one density and media
  18492. returned rgb<.8,.8,.4> and the other returned rgb<.25,.25,0>.
  18493. The resulting color is rgb<1.05,1.05,.4>.  The end result is that
  18494. density areas which overlap will be especially bright and all
  18495. areas will be visible.  This is similar to a CSG union operation.
  18496. See the sample scene scenes/interior/media/media4.pov for an
  18497. example which illustrates this.
  18498.  
  18499.  
  18500. 4.9  Atmospheric Effects
  18501. Atmospheric effects are a loosely-knit group of features that
  18502. affect the background and/or the atmosphere enclosing the scene.
  18503. POV-Ray includes the ability to render a number of atmospheric
  18504. effects, such as fog, haze, mist, rainbows and skies.
  18505.  
  18506.  
  18507. 4.9.1     Atmospheric Media
  18508. Atmospheric effects such as fog, dust, haze, or visible gas may
  18509. be simulated by a media statement specified in the scene but not
  18510. attached to any object.  All areas not inside a non-hollow object
  18511. in the entire scene.  A very simple approach to add fog to a
  18512. scene is explained in section "Fog" however this kind of fog does
  18513. not interact with any light sources like media does. It will not
  18514. show light beams or other effects and is therefore not very
  18515. realistic.
  18516.  
  18517. The atmosphere media effect overcomes some of the fog's
  18518. limitations by calculating the interaction between light and the
  18519. particles in the atmosphere using volume sampling. Thus shaft of
  18520. light beams will become visible and objects will cast shadows
  18521. onto smoke or fog.
  18522.  
  18523. With spotlights you'll be able to create the best results because
  18524. their cone of light will become visible. Pointlights can be used
  18525. to create effects like street lights in fog. Lights can be made
  18526. to not interact with the atmosphere by adding media_interaction
  18527. off to the light source. They can be used to increase the overall
  18528. light level of the scene to make it look more realistic.
  18529.  
  18530. Complete details on media are given in the section "Media".
  18531. Earlier versions of POV-Ray used an atmosphere statement for
  18532. atmospheric effects but that system was incompatible with the old
  18533. object halo system.  So atmosphere has been eliminated and
  18534. replaced with a simpler and more powerful media feature.  The
  18535. user now only has to learn one media system for either
  18536. atmospheric or object use.
  18537.  
  18538. If you only want media effects in a particular area, you should
  18539. use object media rather than only relying upon the media pattern.
  18540. In general it will be faster and more accurate because it only
  18541. calculates inside the constraining object.
  18542.  
  18543. You should note that the atmosphere feature will not work if the
  18544. camera is inside a non-hollow object (see section "Empty and
  18545. Solid Objects" for a detailed explanation).
  18546.  
  18547.  
  18548. 4.9.2     Background
  18549. A background color can be specified if desired. Any ray that
  18550. doesn't hit an object will be colored with this color. The
  18551. default background is black. The syntax for background is:
  18552.  
  18553. BACKGROUND:
  18554.   background {COLOR}
  18555.  
  18556. 4.9.3     Fog
  18557. If it is not necessary for light beams to interact with
  18558. atmospheric media, then fog may be a faster way to simulate haze
  18559. or fog.  This feature artificially adds color to every pixel
  18560. based on the distance the ray has traveled.  The syntax for fog
  18561. is:
  18562.  
  18563. FOG:
  18564.   fog { [FOG_IDENTIFIER] [FOG_ITEMS...] }
  18565. FOG_ITEMS:
  18566.   fog_type Fog_Type   |   distance Distance   |   COLOR   |
  18567.   turbulence <Turbulence>   |   turb_depth Turb_Depth   |
  18568.   omega Omega   |   lambda Lambda   |   octaves Octaves   |
  18569.   fog_offset Fog_Offset   |   fog_alt Fog_Alt   |
  18570.   up <Fog_Up>   |   TRANSFORMATION
  18571. Currently there are two fog types, the default fog_type 1 is a
  18572. constant fog and fog_type 2 is ground fog. The constant fog has a
  18573. constant density everywhere while the ground fog has a constant
  18574. density for all heights below a given point on the up axis and
  18575. thins out along this axis.
  18576.  
  18577. The color of a pixel with an intersection depth d is calculated
  18578. by
  18579.  
  18580.   PIXEL_COLOR = exp(-d/D) * OBJECT_COLOR + (1-exp(-d/D)) *
  18581. FOG_COLOR
  18582.  
  18583. where D is the specified value of the required fog distance
  18584. keyword. At depth 0 the final color is the object's color. If the
  18585. intersection depth equals the fog distance the final color
  18586. consists of 64% of the object's color and 36% of the fog's color.
  18587.  
  18588. For ground fog, the height below which the fog has constant
  18589. density is specified by the fog_offset keyword. The fog_alt
  18590. keyword is used to specify the rate by which the fog fades away.
  18591. The default values for both are 0.0 so be sure to specify them if
  18592. ground fog is used.  At an altitude of Fog_Offset+Fog_Alt the fog
  18593. has a density of 25%. The density of the fog at height less than
  18594. or equal to Fog_Alt is 1.0 and for height y less than Fog_Alt is
  18595. calculated by
  18596.  
  18597.   1/(1 + (y - Fog_Offset) / Fog_Alt) ^2)
  18598.  
  18599. The total density along a ray is calculated by integrating from
  18600. the height of the starting point to the height of the end point.
  18601.  
  18602. The optional up vector specifies a direction pointing up,
  18603. generally the same as the camera's up vector. All calculations
  18604. done during the ground fog evaluation are done relative to this
  18605. up vector, i. e. the actual heights are calculated along this
  18606. vector. The up vector can also be modified using any of the known
  18607. transformations described in "Transformations". Though it may not
  18608. be a good idea to scale the up vector - the results are hardly
  18609. predictable - it is quite useful to be able to rotate it. You
  18610. should also note that translations do not affect the up direction
  18611. (and thus don't affect the fog).
  18612.  
  18613. The required fog color has three purposes. First it defines the
  18614. color to be used in blending the fog and the background. Second
  18615. it is used to specify a translucency threshold. By using a
  18616. transmittance larger than zero one can make sure that at least
  18617. that amount of light will be seen through the fog.  With a
  18618. transmittance of 0.3 you'll see at least 30% of the background.
  18619. Third it can be used to make a filtering fog. With a filter value
  18620. larger than zero the amount of background light given by the
  18621. filter value will be multiplied with the fog color. A filter
  18622. value of 0.7 will lead to a fog that filters 70% of the
  18623. background light and leaves 30% unfiltered.
  18624.  
  18625. Fogs may be layered. That is, you can apply as many layers of fog
  18626. as you like. Generally this is most effective if each layer is a
  18627. ground fog of different color, altitude and with different
  18628. turbulence values. To use multiple layers of fogs, just add all
  18629. of them to the scene.
  18630.  
  18631. You may optionally stir up the fog by adding turbulence. The
  18632. turbulence keyword may be followed by a float or vector to
  18633. specify an amount of turbulence to be used. The omega, lambda and
  18634. octaves turbulence parameters may also be specified. See section
  18635. "Pattern Modifiers" for details on all of these turbulence
  18636. parameters.
  18637.  
  18638. Additionally the fog turbulence may be scaled along the direction
  18639. of the viewing ray using the turb_depth amount. Typical values
  18640. are from 0.0 to 1.0 or more. The default value is 0.5 but any
  18641. float value may be used.
  18642.  
  18643. You should note that the fog feature will not work if the camera
  18644. is inside a non-hollow object (see section "Empty and Solid
  18645. Objects" for a detailed explanation).
  18646.  
  18647.  
  18648. 4.9.4     Sky Sphere
  18649. The sky sphere is used create a realistic sky background without
  18650. the need of an additional sphere to simulate the sky. Its syntax
  18651. is:
  18652.  
  18653. SKY_SPHERE:
  18654.   sky_sphere { [SKY_SPHERE_IDENTIFIER] [SKY_SPHERE_ITEMS...] }
  18655. SKY_SPHERE_ITEM:
  18656.   PIGMENT   |   TRANSFORMATION
  18657. The sky sphere can contain several pigment layers with the last
  18658. pigment being at the top, i. e. it is evaluated last, and the
  18659. first pigment being at the bottom, i. e. it is evaluated first.
  18660. If the upper layers contain filtering and/or transmitting
  18661. components lower layers will shine through. If not lower layers
  18662. will be invisible.
  18663.  
  18664. The sky sphere is calculated by using the direction vector as the
  18665. parameter for evaluating the pigment patterns. This leads to
  18666. results independent from the view point which pretty good models
  18667. a real sky where the distance to the sky is much larger than the
  18668. distances between visible objects.
  18669.  
  18670. If you want to add a nice color blend to your background you can
  18671. easily do this by using the following example.
  18672.  
  18673.   sky_sphere {
  18674.     pigment {
  18675.       gradient y
  18676.       color_map {
  18677.         [ 0.5  color CornflowerBlue ]
  18678.         [ 1.0  color MidnightBlue ]
  18679.       }
  18680.       scale 2
  18681.       translate -1
  18682.     }
  18683.   }
  18684. This gives a soft blend from CornflowerBlue at the horizon to
  18685. MidnightBlue at the zenith. The scale and translate operations
  18686. are used to map the direction vector values, which lie in the
  18687. range from <-1, -1, -1> to <1, 1, 1>, onto the range from <0, 0,
  18688. 0> to <1, 1, 1>. Thus a repetition of the color blend is avoided
  18689. for parts of the sky below the horizon.
  18690.  
  18691. In order to easily animate a sky sphere you can transform it
  18692. using the usual transformations described in "Transformations".
  18693. Though it may not be a good idea to translate or scale a sky
  18694. sphere - the results are hardly predictable - it is quite useful
  18695. to be able to rotate it. In an animation the color blendings of
  18696. the sky can be made to follow the rising sun for example.
  18697.  
  18698. You should note that only one sky sphere can be used in any
  18699. scene. It also will not work as you might expect if you use
  18700. camera types like the orthographic or cylindrical camera. The
  18701. orthographic camera uses parallel rays and thus you'll only see a
  18702. very small part of the sky sphere (you'll get one color skies in
  18703. most cases). Reflections in curved surface will work though, e.
  18704. g. you will clearly see the sky in a mirrored ball.
  18705.  
  18706.  
  18707. 4.9.5     Rainbow
  18708. Rainbows are implemented using fog-like, circular arcs. Their
  18709. syntax is:
  18710.  
  18711. RAINBOW:
  18712.   rainbow { [RAINBOW_IDENTIFIER] [RAINBOW_ITEMS...] }
  18713. RAINBOW_ITEM:
  18714.   direction <Dir>   |   angle Angle   |   width Width   |
  18715. distance Distance   |
  18716.   COLOR_MAP   |   jitter Jitter   |   up <Up>   |
  18717.   arc_angle Arc_Angle   |   falloff_angle Falloff_Angle
  18718. The required direction vector determines the direction of the
  18719. (virtual) light that is responsible for the rainbow. Ideally this
  18720. is an infinitely far away light source like the sun that emits
  18721. parallel light rays. The position and size of the rainbow are
  18722. specified by the required angle and width keywords. To understand
  18723. how they work you should first know how the rainbow is
  18724. calculated.
  18725.  
  18726. For each ray the angle between the rainbow's direction vector and
  18727. the ray's direction vector is calculated. If this angle lies in
  18728. the interval from Angle-Width/2 to Angle+Width/2 the rainbow is
  18729. hit by the ray. The color is then determined by using the angle
  18730. as an index into the rainbow's color_map. After the color has
  18731. been determined it will be mixed with the background color in the
  18732. same way like it is done for fogs.
  18733.  
  18734. Thus the angle and width parameters determine the angles under
  18735. which the rainbow will be seen. The optional jitter keyword can
  18736. be used to add random noise to the index. This adds some
  18737. irregularity to the rainbow that makes it look more realistic.
  18738.  
  18739. The required distance keyword is the same like the one used with
  18740. fogs. Since the rainbow is a fog-like effect it's possible that
  18741. the rainbow is noticeable on objects. If this effect is not
  18742. wanted it can be avoided by using a large distance value. By
  18743. default a sufficiently large value is used to make sure that this
  18744. effect does not occur.
  18745.  
  18746. The color_map statement is used to assign a color map that will
  18747. be mapped onto the rainbow. To be able to create realistic
  18748. rainbows it is important to know that the index into the color
  18749. map increases with the angle between the ray's and rainbow's
  18750. direction vector. The index is zero at the innermost ring and one
  18751. at the outermost ring. The filter and transmittance values of the
  18752. colors in the color map have the same meaning as the ones used
  18753. with fogs (see section "Fog").
  18754.  
  18755. The default rainbow is a 360 degree arc that looks like a circle.
  18756. This is no problem as long as you have a ground plane that hides
  18757. the lower, non-visible part of the rainbow. If this isn't the
  18758. case or if you don't want the full arc to be visible you can use
  18759. the optional keywords up, arc_angle and falloff_angle to specify
  18760. a smaller arc.
  18761.  
  18762. The arc_angle keyword determines the size of the arc in degrees
  18763. (from 0 to 360 degrees). A value smaller than 360 degrees results
  18764. in an arc that abruptly vanishes. Since this doesn't look nice
  18765. you can use the falloff_angle keyword to specify a region in
  18766. which the rainbow will smoothly blend into the background making
  18767. it vanish softly. The falloff angle has to be smaller or equal to
  18768. the arc angle.
  18769.  
  18770. The up keyword determines were the zero angle position is. By
  18771. changing this vector you can rotate the rainbow about its
  18772. direction. You should note that the arc goes from -Arc_Angle/2 to
  18773. +Arc_Angle/2. The soft regions go from -Arc_Angle/2 to -
  18774. Falloff_Angle/2 and from +Falloff_Angle/2 to +Arc_Angle/2.
  18775.  
  18776. The following example generates a 120 degrees rainbow arc that
  18777. has a falloff region of 30 degrees at both ends:
  18778.  
  18779.   rainbow {
  18780.     direction <0, 0, 1>
  18781.     angle 42.5
  18782.     width 5
  18783.     distance 1000
  18784.     jitter 0.01
  18785.     color_map { Rainbow_Color_Map }
  18786.     up <0, 1, 0>
  18787.     arc_angle 120
  18788.     falloff_angle 30
  18789.   }
  18790. It is possible to use any number of rainbows and to combine them
  18791. with other atmospheric effects.
  18792.  
  18793.  
  18794. 4.10 Global Settings
  18795. The global_settings statement is a catch-all statement that
  18796. gathers together a number of global parameters. The statement may
  18797. appear anywhere in a scene as long as it is not inside any other
  18798. statement. You may have multiple global_settings statements in a
  18799. scene. Whatever values were specified in the last global_settings
  18800. statement override any previous settings.  Regardless of where
  18801. you specify the statement, the feature applies to the entire
  18802. scene.
  18803.  
  18804. Note that some items which were language directives in earlier
  18805. versions of POV-Ray have been moved inside the global_settings
  18806. statement so that it is more obvious to the user that their
  18807. effect is global. The old syntax is permitted but generates a
  18808. warning.  The new syntax is:
  18809.  
  18810. GLOBAL_SETTINGS:
  18811.   global_settings { [GLOBAL_SETTINGS_ITEMS...] }
  18812. GLOBAL_SETTINGS_ITEM:
  18813.   adc_bailout Value   |   ambient_light COLOR   |
  18814.   assumed_gamma Value   |
  18815.   hf_gray_16 [Bool}   |   irid_wavelength COLOR   |
  18816.   max_intersections Number   |
  18817.   max_trace_level Number   |   number_of_waves Number   |
  18818.   radiosity { RADIOSITY_ITEMS... }
  18819. Each item is optional and may appear in and order. If an item is
  18820. specified more than once, the last setting overrides previous
  18821. values. Details on each item are given in the following sections.
  18822.  
  18823.  
  18824. 4.10.1    ADC_Bailout
  18825. In scenes with many reflective and transparent surfaces, POV-Ray
  18826. can get bogged down tracing multiple reflections and refractions
  18827. that contribute very little to the color of a particular pixel.
  18828. The program uses a system called Adaptive Depth Control (ADC) to
  18829. stop computing additional reflected or refracted rays when their
  18830. contribution is insignificant.
  18831.  
  18832. You may use the global setting adc_bailout keyword followed by
  18833. float value to specify the point at which a ray's contribution is
  18834. considered insignificant.  For example:
  18835.  
  18836.   global_settings { adc_bailout 0.01 }
  18837. The default value is 1/255, or approximately 0.0039, since a
  18838. change smaller than that could not be visible in a 24 bit image.
  18839. Generally this setting is perfectly adequate and should be left
  18840. alone. Setting adc_bailout to 0 will disable ADC, relying
  18841. completely on max_trace_level to set an upper limit on the number
  18842. of rays spawned.
  18843.  
  18844. See section "Max_Trace_Level" for details on how ADC and
  18845. max_trace_level interact.
  18846.  
  18847.  
  18848. 4.10.2    Ambient Light
  18849. Ambient light is used to simulate the effect of inter-diffuse
  18850. reflection that is responsible for lighting areas that partially
  18851. or completely lie in shadow.  POV-Ray provides the ambient_light
  18852. keyword to let you easily change the brightness of the ambient
  18853. lighting without changing every ambient value in all finish
  18854. statements. It also lets you create interesting effects by
  18855. changing the color of the ambient light source. The syntax is:
  18856.  
  18857.   global_settings { ambient_light COLOR }
  18858. The default is a white ambient light source set at rgb <1,1,1>.
  18859. Only the rgb components are used.  The actual ambient used is:
  18860. Ambient = Finish_Ambient * Global_Ambient.
  18861.  
  18862. See section "Ambient" for more information.
  18863.  
  18864.  
  18865. 4.10.3    Assumed_Gamma
  18866. Many people may have noticed at one time or another that some
  18867. images are too bright or dim when displayed on their system. As a
  18868. rule, Macintosh users find that images created on a PC are too
  18869. bright, while PC users find that images created on a Macintosh
  18870. are too dim.
  18871.  
  18872. The assumed_gamma global setting works in conjunction with the
  18873. Display_Gamma INI setting (see section "Display Hardware
  18874. Settings") to ensure that scene files render the same way across
  18875. the wide variety of hardware platforms that POV-Ray is used on.
  18876. The assumed gamma setting is used in a scene file by adding
  18877.  
  18878.   global_settings { assumed_gamma Value }
  18879. where the assumed gamma value is the correction factor to be
  18880. applied before the pixels are displayed and/or saved to disk. For
  18881. scenes created in older versions of POV-Ray, the assumed gamma
  18882. value will be the same as the display gamma value of the system
  18883. the scene was created on. For PC systems, the most common display
  18884. gamma is 2.2, while for scenes created on Macintosh systems
  18885. should use a scene gamma of 1.8. Another gamma value that
  18886. sometimes occurs in scenes is 1.0.
  18887.  
  18888. Scenes that do not have an assumed_gamma global setting will not
  18889. have any gamma correction performed on them, for compatibility
  18890. reasons. If you are creating new scenes or rendering old scenes,
  18891. it is strongly recommended that you put in an appropriate
  18892. assumed_gamma global setting. For new scenes, you should use an
  18893. assumed gamma value of 1.0 as this models how light appears in
  18894. the real world more realistically.
  18895.  
  18896. The following sections explain more thoroughly what gamma is and
  18897. why it is important.
  18898.  
  18899.  
  18900. 4.10.3.1  Monitor Gamma
  18901. The differences in how images are displayed is a result of how a
  18902. computer actually takes an image and displays it on the monitor.
  18903. In the process of rendering an image and displaying it on the
  18904. screen, several gamma values are important, including the POV
  18905. scene file or image file gamma and the monitor gamma.
  18906.  
  18907. Most image files generated by POV-Ray store numbers in the range
  18908. from 0 to 255 for each of the red, green and blue components of a
  18909. pixel. These numbers represent the intensity of each color
  18910. component, with 0 being black and 255 being the brightest color
  18911. (either 100% red, 100% green or 100% blue). When an image is
  18912. displayed, the graphics card converts each color component into a
  18913. voltage which is sent to the monitor to light up the red, green
  18914. and blue phosphors on the screen.  The voltage is usually
  18915. proportional to the value of each color component.
  18916.  
  18917. Gamma becomes important when displaying intensities that aren't
  18918. the maximum or minimum possible values. For example, 127 should
  18919. represent 50% of the maximum intensity for pixels stored as
  18920. numbers between 0 and 255. On systems that don't do gamma
  18921. correction, 127 will be converted to 50% of the maximum voltage,
  18922. but because of the way the phosphors and the electron guns in a
  18923. monitor work, this may be only 22% of the maximum color intensity
  18924. on a monitor with a gamma of 2.2.  To display a pixel which is
  18925. 50% of the maximum intensity on this monitor, we would need a
  18926. voltage of 73% of the maximum voltage, which translates to
  18927. storing a pixel value of 186.
  18928.  
  18929. The relationship between the input pixel value and the displayed
  18930. intensity can be approximated by an exponential function obright
  18931. = ibright ^ display_gamma where obright is the output intensity
  18932. and ibright is the input pixel intensity. Both values are in the
  18933. range from 0 to 1 (0% to 100%). Most monitors have a fixed gamma
  18934. value in the range from 1.8 to 2.6. Using the above formula with
  18935. display_gamma values greater than 1 means that the output
  18936. brightness will be less than the input brightness. In order to
  18937. have the output and input brightness be equal an overall system
  18938. gamma of 1 is needed. To do this, we need to gamma correct the
  18939. input brightness in the same manner as above but with a gamma
  18940. value of 1/display_gamma before it is sent to the monitor. To
  18941. correct for a display gamma of 2.2, this pre-monitor gamma
  18942. correction uses a gamma value of 1.0/2.2 or approximately 0.45.
  18943.  
  18944. How the pre-monitor gamma correction is done depends on what
  18945. hardware and software is being used. On Macintosh systems, the
  18946. operating system has taken it upon itself to insulate
  18947. applications from the differences in display hardware. Through a
  18948. gamma control panel the user may be able to set the actual
  18949. monitor gamma and Mac will then convert all pixel intensities so
  18950. that the monitor will appear to have the specified gamma value.
  18951. On Silicon Graphics machines, the display adapter has built-in
  18952. gamma correction calibrated to the monitor which gives the
  18953. desired overall gamma (the default is 1.7). Unfortunately, on PCs
  18954. and most UNIX systems, it is up to the application to do any
  18955. gamma correction needed.
  18956.  
  18957.  
  18958. 4.10.3.2  Image File Gamma
  18959. Since most PC and UNIX applications and image file formats don't
  18960. understand display gamma, they don't do anything to correct for
  18961. it.  As a result, users creating images on these systems adjust
  18962. the image in such a way that it has the correct brightness when
  18963. displayed. This means that the data values stored in the files
  18964. are made brighter to compensate for the darkening effect of the
  18965. monitor. In essence, the 0.45 gamma correction is built in to the
  18966. image files created and stored on these systems. When these files
  18967. are displayed on a Macintosh system, the gamma correction built
  18968. in to the file, in addition to gamma correction built into MacOS,
  18969. means that the image will be too bright. Similarly, files that
  18970. look correct on Macintosh or SGI systems because of the built-in
  18971. gamma correction will be too dark when displayed on a PC.
  18972.  
  18973. The new PNG format files generated by POV-Ray 3.0 overcome the
  18974. problem of too much or not enough gamma correction by storing the
  18975. image file gamma (which is 1.0/display_gamma) inside the PNG file
  18976. when it is generated by POV-Ray. When the PNG file is later
  18977. displayed by a program that has been set up correctly, it uses
  18978. this gamma value as well as the current display gamma to correct
  18979. for the potentially different display gamma used when originally
  18980. creating the image.
  18981.  
  18982. Unfortunately, of all the image file formats POV-Ray supports,
  18983. PNG is the only one that has any gamma correction features and is
  18984. therefore preferred for images that will be displayed on a wide
  18985. variety of platforms.
  18986.  
  18987.  
  18988. 4.10.3.3  Scene File Gamma
  18989. The image file gamma problem itself is just a result of how
  18990. scenes themselves are generated in POV-Ray. When you start out
  18991. with a new scene and are placing light sources and adjusting
  18992. surface textures and colors, you generally make several attempts
  18993. before the lighting is how you like it. How you choose these
  18994. settings depends upon the preview image or the image file stored
  18995. to disk, which in turn is dependent upon the overall gamma of the
  18996. display hardware being used.
  18997.  
  18998. This means that as the artist you are doing gamma correction in
  18999. the POV-Ray scene file for your particular hardware. This scene
  19000. file will generate an image file that is also gamma corrected for
  19001. your hardware and will display correctly on systems similar to
  19002. your own.  However, when this scene is rendered on another
  19003. platform, it may be too bright or too dim, regardless of the
  19004. output file format used.  Rather than have you change all the
  19005. scene files to have a single fixed gamma value (heaven forbid!),
  19006. POV-Ray 3.0 allows you to specify in the scene file the display
  19007. gamma of the system that the scene was created on.
  19008.  
  19009. The assumed_gamma global setting, in conjunction with the
  19010. Display_Gamma INI setting lets POV-Ray know how to do gamma
  19011. correction on a given scene so that the preview and output image
  19012. files will appear the correct brightness on any system. Since the
  19013. gamma correction is done internally to POV-Ray, it will produce
  19014. output image files that are the correct brightness for the
  19015. current display, regardless of what output format is used. As
  19016. well, since the gamma correction is performed in the high-
  19017. precision data format that POV-Ray uses internally, it produces
  19018. better results than gamma correction done after the file is
  19019. written to disk.
  19020.  
  19021. Although you may not notice any difference in the output on your
  19022. system with and without an assumed_gamma setting, the assumed
  19023. gamma is important if the scene is ever rendered on another
  19024. platform.
  19025.  
  19026.  
  19027. 4.10.4    HF_Gray_16
  19028. The hf_gray_16 setting is useful when using POV-Ray to generate
  19029. heightfields for use in other POV-Ray scenes. The syntax is...
  19030.  
  19031.   global_settings { hf_gray_16 [Bool] }
  19032. The boolean value turns the option on or off. If the keyword is
  19033. specified without the boolean value then the option is turned on.
  19034. If hf_gray_16 is not specified in any global_settings statement
  19035. in the entire scene then the default is off.
  19036.  
  19037. When hf_gray_16 is on, the output file will be in the form of a
  19038. heightfield, with the height at any point being dependent on the
  19039. brightness of the pixel. The brightness of a pixel is calculated
  19040. in the same way that color images are converted to grayscale
  19041. images:  height = 0.3 * red + 0.59 * green + 0.11 * blue.
  19042.  
  19043. Setting the hf_gray_16 option will cause the preview display, if
  19044. used, to be grayscale rather than color. This is to allow you to
  19045. see how the heightfield will look because some file formats store
  19046. heightfields in a way that is difficult to understand afterwards.
  19047. See section "Height Field" for a description of how POV-Ray
  19048. heightfields are stored for each file type.
  19049.  
  19050.  
  19051. 4.10.5    Irid_Wavelength
  19052. Iridescence calculations depend upon the dominant wavelengths of
  19053. the primary colors of red, green and blue light. You may adjust
  19054. the values using the global setting irid_wavelength as follows...
  19055.  
  19056.   global_settings { irid_wavelength COLOR }
  19057. The default value is rgb <0.25,0.18,0.14> and any filter or
  19058. transmit values are ignored. These values are proportional to the
  19059. wavelength of light but they represent no real world units.
  19060.  
  19061. In general, the default values should prove adequate but we
  19062. provide this option as a means to experiment with other values.
  19063.  
  19064.  
  19065. 4.10.6    Max_Trace_Level
  19066. In scenes with many reflective and transparent surfaces POV-Ray
  19067. can get bogged down tracing multiple reflections and refractions
  19068. that contribute very little to the color of a particular pixel.
  19069. The global setting max_trace_level defines the integer maximum
  19070. number of recursive levels that POV-Ray will trace a ray.
  19071.  
  19072.   global_settings { max_trace_level Level }
  19073. This is used when a ray is reflected or is passing through a
  19074. transparent object and when shadow rays are cast. When a ray hits
  19075. a reflective surface, it spawns another ray to see what that
  19076. point reflects. That is trace level one. If it hits another
  19077. reflective surface another ray is spawned and it goes to trace
  19078. level two.  The maximum level by default is five.
  19079.  
  19080. One speed enhancement added to POV-Ray in version 3.0 is Adaptive
  19081. Depth Control (ADC). Each time a new ray is spawned as a result
  19082. of reflection or refraction its contribution to the overall color
  19083. of the pixel is reduced by the amount of reflection or the filter
  19084. value of the refractive surface. At some point this contribution
  19085. can be considered to be insignificant and there is no point in
  19086. tracing any more rays. Adaptive depth control is what tracks this
  19087. contribution and makes the decision of when to bail out. On
  19088. scenes that use a lot of partially reflective or refractive
  19089. surfaces this can result in a considerable reduction in the
  19090. number of rays fired and makes it safer to use much higher
  19091. max_trace_level values.
  19092.  
  19093. This reduction in color contribution is a result of scaling by
  19094. the reflection amount and/or the filter values of each surface,
  19095. so a perfect mirror or perfectly clear surface will not be
  19096. optimizable by ADC. You can see the results of ADC by watching
  19097. the Rays Saved and Highest Trace Level displays on the statistics
  19098. screen.
  19099.  
  19100. The point at which a ray's contribution is considered
  19101. insignificant is controlled by the adc_bailout value. The default
  19102. is 1/255 or approximately 0.0039 since a change smaller than that
  19103. could not be visible in a 24 bit image.  Generally this setting
  19104. is perfectly adequate and should be left alone. Setting
  19105. adc_bailout to 0 will disable ADC, relying completely on
  19106. max_trace_level to set an upper limit on the number of rays
  19107. spawned.
  19108.  
  19109. If max_trace_level is reached before a non-reflecting surface is
  19110. found and if ADC hasn't allowed an early exit from the ray tree
  19111. the color is returned as black. Raise max_trace_level if you see
  19112. black areas in a reflective surface where there should be a
  19113. color.
  19114.  
  19115. The other symptom you could see is with transparent objects. For
  19116. instance, try making a union of concentric spheres with a clear
  19117. texture on them. Make ten of them in the union with radius's from
  19118. 1 to 10 and render the scene. The image will show the first few
  19119. spheres correctly, then black. This is because a new level is
  19120. used every time you pass through a transparent surface. Raise
  19121. max_trace_level to fix this problem.
  19122.  
  19123. Note that raising max_trace_level will use more memory and time
  19124. and it could cause the program to crash with a stack overflow
  19125. error, although ADC will alleviate this to a large extent. Values
  19126. for max_trace_level are not restricted, so it can be set to any
  19127. number as long as you have the time and memory. However,
  19128. increasing its setting does not necessarily equate to increased
  19129. image quality unless such depths are really needed by the scene.
  19130.  
  19131.  
  19132. 4.10.7    Max_Intersections
  19133. POV-Ray uses a set of internal stacks to collect ray/object
  19134. intersection points. The usual maximum number of entries in these
  19135. I-Stacks is 64. Complex scenes may cause these stacks to
  19136. overflow.  POV-Ray doesn't stop but it may incorrectly render
  19137. your scene. When POV-Ray finishes rendering, a number of
  19138. statistics are displayed. If you see I-Stack Overflows reported
  19139. in the statistics you should increase the stack size. Add a
  19140. global setting to your scene as follows:
  19141.  
  19142.   global_settings { max_intersections Integer }
  19143. If the I-Stack Overflows remain increase this value until they
  19144. stop.
  19145.  
  19146.  
  19147. 4.10.8    Number_Of_Waves
  19148. The waves and ripples pattern are generated by summing a series
  19149. of waves, each with a slightly different center and size. By
  19150. default, ten waves are summed but this amount can be globally
  19151. controlled by changing the number_of_waves setting.
  19152.  
  19153.   global_settings { number_of_waves Integer }
  19154. Changing this value affects both waves and ripples alike on all
  19155. patterns in the scene.
  19156.  
  19157.  
  19158. 4.10.9    Radiosity
  19159. Important notice: The radiosity features in POV-Ray are somewhat
  19160. experimental. There is a high probability that the design and
  19161. implementation of these features will be changed in future
  19162. versions. We cannot guarantee that scenes using these features in
  19163. this version will render identically in future releases or that
  19164. full backwards compatibility of language syntax can be
  19165. maintained.
  19166.  
  19167. Radiosity is an extra calculation that more realistically
  19168. computes the diffuse interreflection of light. This diffuse
  19169. interreflection can be seen if you place a white chair in a room
  19170. full of blue carpet, blue walls and blue curtains. The chair will
  19171. pick up a blue tint from light reflecting off of other parts of
  19172. the room. Also notice that the shadowed areas of your
  19173. surroundings are not totally dark even if no light source shines
  19174. directly on the surface. Diffuse light reflecting off of other
  19175. objects fills in the shadows. Typically ray-tracing uses a trick
  19176. called ambient light to simulate such effects but it is not very
  19177. accurate.
  19178.  
  19179. Radiosity is more accurate than simplistic ambient light but it
  19180. takes much longer to compute. For this reason, POV-Ray does not
  19181. use radiosity by default. Radiosity is turned on using the
  19182. Radiosity INI file option or the +QR command line switch.
  19183.  
  19184. The following sections describes how radiosity works, how to
  19185. control it with various global settings and tips on trading
  19186. quality vs.  speed.
  19187.  
  19188.  
  19189. 4.10.9.1  How Radiosity Works
  19190. The problem of ray-tracing is to figure out what the light level
  19191. is at each point that you can see in a scene. Traditionally, in
  19192. ray tracing, this is broken into the sum of these components:
  19193.  
  19194.   -  Diffuse, the effect that makes the side of things facing the
  19195.   light brighter;
  19196.   -  Specular, the effect that makes shiny things have dings or
  19197.   sparkles on them;
  19198.   -  Reflection, the effect that mirrors give; and
  19199.   -  Ambient, the general all-over light level that any scene
  19200.   has, which keeps things in shadow from being pure black.
  19201. POV-Ray's radiosity system, based on a method by Greg Ward,
  19202. provides a way to replace the last term - the constant ambient
  19203. light value - with a light level which is based on what surfaces
  19204. are nearby and how bright in turn they are.
  19205.  
  19206. The first thing you might notice about this definition is that it
  19207. is circular: the light of everything is dependent on everything
  19208. else and vice versa. This is true in real life but in the world
  19209. of ray-tracing, we can make an approximation. The approximation
  19210. that is used is: the objects you are looking at have their
  19211. ambient values calculated for you by checking the other objects
  19212. nearby. When those objects are checked during this process,
  19213. however, a traditional constant ambient term is used.
  19214.  
  19215. How does POV-Ray calculate the ambient term for each point? By
  19216. sending out more rays, in many different directions, and
  19217. averaging the results. A typical point might use 200 or more rays
  19218. to calculate its ambient light level correctly.
  19219.  
  19220. Now this sounds like it would make the ray-tracer 200 times
  19221. slower. This is true, except that the software takes advantage of
  19222. the fact that ambient light levels change quite slowly (remember,
  19223. shadows are calculated separately, so sharp shadow edges are not
  19224. a problem). Therefore, these extra rays are sent out only once in
  19225. a while (about 1 time in 50), then these calculated values are
  19226. saved and reused for nearby pixels in the image when possible.
  19227.  
  19228. This process of saving and reusing values is what causes the need
  19229. for a variety of tuning parameters, so you can get the scene to
  19230. look just the way you want.
  19231.  
  19232.  
  19233. 4.10.9.2  Adjusting Radiosity
  19234. As described earlier, radiosity is turned on by using the
  19235. Radiosity INI file option or the +QR command line switch. However
  19236. radiosity has many parameters that are specified in a radiosity
  19237. statement inside a global_settings statement as follows:
  19238.  
  19239.   global_settings { radiosity { [RADIOSITY_ITEMS...] }}
  19240. RADIOSITY_ITEMS:
  19241.   brightness Float   |   count Integer   |   distance_maximum
  19242.   Float   |
  19243.   error_bound Float   |   gray_threshold Float   |
  19244.   low_error_factor Float   |
  19245.   minimum_reuse Float   |   nearest_count Integer   |
  19246.   recursion_limit Integer
  19247. Each item is optional and may appear in and order. If an item is
  19248. specified more than once the last setting overrides previous
  19249. values. Details on each item is given in the following sections.
  19250.  
  19251.  
  19252. 4.10.9.2.1     brightness
  19253. This brightness keyword specifies a float value that is the
  19254. degree to which ambient values are brightened before being
  19255. returned upwards to the rest of the system. If an object is red
  19256. rgb<1,0 0>, with an ambient value of 0.3, in normal situations a
  19257. red component of 0.3 will be added in. With radiosity on, assume
  19258. it was surrounded by an object of gray color rgb<0.6,0.6,0.6>.
  19259. The average color returned by the gathering process will be the
  19260. same. This will be multiplied by the texture's ambient weight
  19261. value of 0.3, returning rgb<0.18,0.18,0.18>. This is much darker
  19262. than the 0.3 which would be added in normally. Therefore, all
  19263. returned values are brightened by the inverse of the average of
  19264. the calculated values, so the average ambient added in does not
  19265. change.  Some will be higher than specified (higher than 0.3 in
  19266. this example) and some will be lower but the overall scene
  19267. brightness will be unchanged.  The default value is 3.3.
  19268.  
  19269.  
  19270. 4.10.9.2.2     count
  19271. The integer number of rays that are sent out whenever a new
  19272. radiosity value has to be calculated is given by count. Values of
  19273. 100 to 150 make most scenes look good.  Higher values might be
  19274. needed for scenes with high contrast between light levels or
  19275. small patches of light causing the illumination.  This would be
  19276. used only for a final rendering on an image because it is very
  19277. compute intensive. Since most scenes calculate the ambient value
  19278. at 1% to 2% of pixels, as a rough estimate, your rendering will
  19279. take 1% to 2% of this number times as long. If you set it to 300
  19280. your rendering might take 3 to 6 times as long to complete (1% to
  19281. 2% times 300).
  19282.  
  19283. When this value is too low, the light level will tend to look a
  19284. little bit blotchy, as if the surfaces you're looking at were
  19285. slightly warped. If this is not important to your scene (as in
  19286. the case that you have a bump map or if you have a strong
  19287. texture) then by all means use a lower number.  The default value
  19288. is 100.
  19289.  
  19290.  
  19291. 4.10.9.2.3     distance_maximum
  19292. The distance_maximum float value is the only tuning value that
  19293. depends upon the size of the objects in the scene. This one must
  19294. be set for scenes to render properly... the rest can be ignored
  19295. for a first try. It is difficult to describe the meaning simply
  19296. but it sets the distance in model units from a sample at which
  19297. the error is guaranteed to hit 100% (radiosity_error_bound >=1):
  19298. no samples are reused at a distance larger than this from their
  19299. original calculation point.
  19300.  
  19301. Imagine an apple at the left edge of a table. The goal is to make
  19302. sure that samples on the surface of the table at the right are
  19303. not used too close to the apple and definitely not underneath the
  19304. apple.  If you had enough rays there wouldn't be a problem since
  19305. one of them would be guaranteed to hit the apple and set the
  19306. reuse radius properly for you. In practice, you must limit this.
  19307.  
  19308. We use this technique: find the object in your scene which might
  19309. have the following problem: a small object on a larger flatter
  19310. surface that you want good ambient light near. Now, how far from
  19311. this would you have to get to be sure that one of your rays had a
  19312. good chance of hitting it? In the apple-on-the-table example,
  19313. assuming I used one POV-Ray unit as one inch, I might use 30
  19314. inches. A theoretically sound way (when you are running lots of
  19315. rays) is the distance at which this object's top is 5 degrees
  19316. above the horizon of the sample point you are considering. This
  19317. corresponds to about 11 times the height of the object. So, for a
  19318. 3-inch apple, 33 inches makes some sense. For good behavior under
  19319. and around a 1/3 inch pea, use 3 inches etc. Another VERY rough
  19320. estimate is one third the distance from your eye position to the
  19321. point you are looking at. The reasoning is that you are probably
  19322. no more than 90 inches from the apple on the table, if you care
  19323. about the shading underneath it.  The default value is 0.
  19324.  
  19325.  
  19326. 4.10.9.2.4     error_bound
  19327. The error_bound float value is one of the two main speed/quality
  19328. tuning values (the other is of course the number of rays shot).
  19329. In an ideal world, this would be the only value needed. It is
  19330. intended to mean the fraction of error tolerated. For example, if
  19331. it were set to 1 the algorithm would not calculate a new value
  19332. until the error on the last one was estimated at as high as 100%.
  19333. Ignoring the error introduced by rotation for the moment, on flat
  19334. surfaces this is equal to the fraction of the reuse distance,
  19335. which in turn is the distance to the closest item hit. If you
  19336. have an old sample on the floor 10 inches from a wall, an error
  19337. bound of 0.5 will get you a new sample at a distance of about 5
  19338. inches from the wall. 0.5 is a little rough and ready, 0.33 is
  19339. good for final renderings. Values much lower than 0.3 take
  19340. forever. The default value is 0.4.
  19341.  
  19342.  
  19343. 4.10.9.2.5     gray_threshold
  19344. Diffusely interreflected light is a function of the objects
  19345. around the point in question. Since this is recursively defined
  19346. to millions of levels of recursion, in any real life scene, every
  19347. point is illuminated at least in part by every other part of the
  19348. scene. Since we can't afford to compute this, we only do one
  19349. bounce and the calculated ambient light is very strongly affected
  19350. by the colors of the objects near it. This is known as color
  19351. bleed and it really happens but not as much as this calculation
  19352. method would have you believe. The gray_threshold float value
  19353. grays it down a little, to make your scene more believable. A
  19354. value of .6 means to calculate the ambient value as 60% of the
  19355. equivalent gray value calculated, plus 40% of the actual value
  19356. calculated. At 0%, this feature does nothing. At 100%, you always
  19357. get white/gray ambient light, with no hue. Note that this does
  19358. not change the lightness/darkness, only the strength of
  19359. hue/grayness (in HLS terms, it changes S only).  The default
  19360. value is 0.5
  19361.  
  19362.  
  19363. 4.10.9.2.6     low_error_factor
  19364. If you calculate just enough samples, but no more, you will get
  19365. an image which has slightly blotchy lighting. What you want is
  19366. just a few extra interspersed, so that the blending will be nice
  19367. and smooth.  The solution to this is the mosaic preview: it goes
  19368. over the image one or more times beforehand, calculating
  19369. radiosity values. To ensure that you get a few extra, the
  19370. radiosity algorithm lowers the error bound during the pre-final
  19371. passes, then sets it back just before the final pass. The
  19372. low_error_factor is a float tuning value which sets the amount
  19373. that the error bound is dropped during the preliminary image
  19374. passes. If your low error factor is 0.8 and your error bound is
  19375. set to 0.4 it will really use an error bound of 0.32 during the
  19376. first passes and 0.4 on the final pass.  The default value is
  19377. 0.8.
  19378.  
  19379.  
  19380. 4.10.9.2.7     minimum_reuse
  19381. The minimum effective radius ratio is set by minimum_reuse float
  19382. value. This is the fraction of the screen width which sets the
  19383. minimum radius of reuse for each sample point (actually, it is
  19384. the fraction of the distance from the eye but the two are roughly
  19385. equal). For example, if the value is 0.02 the radius of maximum
  19386. reuse for every sample is set to whatever ground distance
  19387. corresponds to 2% of the width of the screen. Imagine you sent a
  19388. ray off to the horizon and it hits the ground at a distance of
  19389. 100 miles from your eye point. The reuse distance for that sample
  19390. will be set to 2 miles. At a resolution of 300*400 this will
  19391. correspond to (very roughly) 8 pixels. The theory is that you
  19392. don't want to calculate values for every pixel into every crevice
  19393. everywhere in the scene, it will take too long. This sets a
  19394. minimum bound for the reuse. If this value is too low, (which it
  19395. should be in theory) rendering gets slow, and inside corners can
  19396. get a little grainy. If it is set too high, you don't get the
  19397. natural darkening of illumination near inside edges, since it
  19398. reuses. At values higher than 2% you start getting more just
  19399. plain errors, like reusing the illumination of the open table
  19400. underneath the apple.  Remember that this is a unitless ratio.
  19401. The default value is 0.015.
  19402.  
  19403.  
  19404. 4.10.9.2.8     nearest_count
  19405. The nearest_count integer value is the maximum number of old
  19406. ambient values blended together to create a new interpolated
  19407. value. It will always be the n geometrically closest reusable
  19408. points that get used. If you go lower than 4, things can get
  19409. pretty patchy. This can be good for debugging, though. Must be no
  19410. more than 10, since that is the size of the array allocated.  The
  19411. default value is 6.
  19412.  
  19413.  
  19414. 4.10.9.2.9     recursion_limit
  19415. The recursion_limit is an integer value which determines how many
  19416. recursion levels are used to calculate the diffuse inter-
  19417. reflection. Valid values are one and two. The default value is 1.
  19418.  
  19419.  
  19420. 4.10.9.3  Tips on Radiosity
  19421. If you want to see where your values are being calculated set
  19422. radiosity count down to about 20, set radiosity nearest_count to
  19423. 1 and set gray_threshold to 0. This will make everything
  19424. maximally patchy, so you'll be able to see the borders between
  19425. patches. There will have been a radiosity calculation at the
  19426. center of most patches. As a bonus, this is quick to run. You can
  19427. then change the error_bound up and down to see how it changes
  19428. things. Likewise modify minimum_reuse and distance_maximum.
  19429.  
  19430. One way to get extra smooth results: crank up the sample count
  19431. (we've gone as high as 1300) and drop the low_error_factor to
  19432. something small like 0.6. Bump up the nearest_count to 7 or 8.
  19433. This will get better values, and more of them, then interpolate
  19434. among more of them on the last pass. This is not for people with
  19435. a lack of patience since it is like a squared function. If your
  19436. blotchiness is only in certain corners or near certain objects
  19437. try tuning the error bound instead. Never drop it by more than a
  19438. little at a time, since the run time will get very long.
  19439.  
  19440. If your scene looks good but right near some objects you get
  19441. spots of the right (usually darker) color showing on a flat
  19442. surface of the wrong color (same as far away from the object),
  19443. then try dropping distance_maximum. If that still doesn't work
  19444. well increase your ray count by 100 and drop the error bound just
  19445. a bit. If you still have problems, drop nearest_count to about 4.
  19446.  
  19447.  
  19448. 5    APPENDICES
  19449.  
  19450. 5.1  Copyright, Legal Information and License -- POVLEGAL.DOC
  19451. The following sections contain the legal information and license
  19452. for the Persistence of Vision(tm) Ray-Tracer, also called POV-Ray(tm).
  19453. Before you use this program you have to read the sections below.
  19454.  
  19455.  
  19456. 5.1.1     General License Agreement -- POVLEGAL.DOC
  19457. Revised June 1998.
  19458.  
  19459. THIS NOTICE MUST ACCOMPANY ALL OFFICIAL OR CUSTOM PERSISTENCE OF
  19460. VISION FILES. IT MAY NOT BE REMOVED OR MODIFIED. THIS INFORMATION
  19461. PERTAINS TO ALL USE OF THE PACKAGE WORLDWIDE.  THIS DOCUMENT
  19462. SUPERSEDES ALL PREVIOUS GENERAL LICENSES OR DISTRIBUTION
  19463. POLICIES. ANY INDIVIDUALS, COMPANIES OR GROUPS WHO HAVE BEEN
  19464. GRANTED SPECIAL LICENSES MAY CONTINUE TO DISTRIBUTE VERSION 2.x
  19465. BUT MUST RE-APPLY FOR VERSION 3.00 OR LATER.
  19466.  
  19467. This document pertains to the use and distribution of the
  19468. Persistence of Vision(tm) Ray Tracer a.k.a POV-Ray(tm). It applies to
  19469. all POV-Ray program source files, executable (binary) files,
  19470. scene files, documentation files, help file, bitmaps and INI
  19471. files contained in official POV-Ray Team(tm) archives.  All of these
  19472. are referred to here as "the software". The POV-Team reserves the
  19473. right to revise these rules in future versions and to make
  19474. additional rules to address new circumstances at any time.
  19475.  
  19476. All of this software is Copyright 1991,1998 by the POV-Ray Team(tm).
  19477. Although it is distributed as freeware, it is NOT PUBLIC DOMAIN.
  19478.  
  19479. The copyrighted package may ONLY be distributed and/or modified
  19480. according to the license granted herein.  The spirit of the
  19481. license is to promote POV-Ray as a standard ray tracer, provide
  19482. the full POV-Ray package freely to as many users as possible,
  19483. prevent POV-Ray users and developers from being taken advantage
  19484. of, enhance the life quality of those who come in contact with
  19485. POV-Ray.  This license was created so these goals could be
  19486. realized.  You are legally bound to follow these rules, but we
  19487. hope you will follow them as a matter of ethics, rather than fear
  19488. of litigation.
  19489.  
  19490.  
  19491. 5.1.2     Usage Provisions
  19492. Permission is granted to the user to use the software and
  19493. associated files in this package to create and render images. The
  19494. use of this software for the purpose of creating images is
  19495. completely free. The creator of a scene file and the image
  19496. created from the scene file, retains all rights to the image and
  19497. scene file they created and may use them for any purpose
  19498. commercial or non-commercial.
  19499.  
  19500. The user is also granted the right to use the scenes files,
  19501. fonts, bitmaps, and include files distributed in the INCLUDE and
  19502. SCENES\INCDEMO sub- directories in their own scenes.  Such
  19503. permission does not extend to files in the SCENES directory or
  19504. its sub-directories.  The SCENES files are for your enjoyment and
  19505. education but may not be the basis of any derivative works.
  19506.  
  19507.  
  19508. 5.1.3     General Rules For All Distribution
  19509. The permission to distribute this package under certain very
  19510. specific conditions is granted in advance, provided that the
  19511. following conditions are met.
  19512.  
  19513. These archives must not be re-archived using a different method
  19514. without the explicit permission of the POV-Team.  You may rename
  19515. the archives only to meet the file name conventions of your
  19516. system or to avoid file name duplications but we ask that you try
  19517. to keep file names as similar to the originals as possible.  (For
  19518. example: POVSRC.ZIP to POVSRC30.ZIP)
  19519.  
  19520. Ready-to-run unarchived distribution on CD-ROM is also permitted
  19521. if the files are arranged in our standard directory or folder
  19522. structure as though it had been properly installed on a hard
  19523. disk.
  19524.  
  19525. You must distribute a FULL PACKAGE of files as described in the
  19526. next section.  No portion of this package may be separated from
  19527. the package and distributed separately other than under the
  19528. conditions specified in the provisions given below.
  19529.  
  19530. Non-commercial distribution in which no money or compensation is
  19531. charged (such as a user copying the software for a personal
  19532. friend or colleague) is permitted with no other restrictions.
  19533.  
  19534. Teachers and educational institutions may also distribute the
  19535. material to students for free or they may charge minimal copying
  19536. costs if the software is to be used in a course.
  19537.  
  19538.  
  19539. 5.1.4     Definition Of "Full Package"
  19540. A "full package" contains an executable program, documentation,
  19541. and sample scenes.  For generic Unix platforms, there are no
  19542. executables available so the portable C source code must be
  19543. included instead of the executable program.
  19544.  
  19545. POV-Ray is officially distributed for MS-Dos; Windows 95/98/NT;
  19546. Linux for Intel x86 series; Apple Macintosh; Apple PowerPC;
  19547. SunOS; and Amiga. Other systems may be added in the future.
  19548.  
  19549. Distributors need not support all platforms but for each platform
  19550. you support you must distribute a full package. For example a
  19551. Macintosh only CD-ROM need not distribute the Windows versions.
  19552.  
  19553. This software may ONLY be bundled with other software packages
  19554. according to the conditions specified in the provisions below.
  19555.  
  19556.  
  19557. 5.1.5     Conditions For Shareware/Freeware Distribution
  19558.      Companies
  19559. Shareware and freeware distribution companies may distribute the
  19560. software included in software-only compilations using media such
  19561. as, but not limited to, floppy disk, CD-ROM, tape backup, optical
  19562. disks, hard disks, or memory cards. This section only applies to
  19563. distributors of collected programs. Anyone wishing to bundle the
  19564. package with a shareware product must use the commercial bundling
  19565. rules.
  19566.  
  19567. For floppy disk distribution, no more than five dollars U.S. ($5)
  19568. can be charged per disk for the copying of this software and the
  19569. media it is provided on. Space on each disk must be used as fully
  19570. as possible. You may not spread the files over more disks than
  19571. are necessary.
  19572.  
  19573. Distribution on high capacity media such as backup tape or CD-ROM
  19574. is permitted if the total cost to the user is no more than $0.08
  19575. U.S. dollars per megabyte of data. For example a CD-ROM with 600
  19576. meg could cost no more than $48.00 US. Any bundling with books,
  19577. magazines or other print media is permitted if the total cost of
  19578. the book or magazine with CD is less than the $48.00 limit.
  19579. Bundling with more expensive publications or distributions should
  19580. also use the commercial rules.
  19581.  
  19582.  
  19583. 5.1.6     Conditions For On-Line Services And Bbs's Including
  19584.      Internet
  19585. On-line services, BBS's and internet sites may distribute the POV-
  19586. Ray software under the conditions in this section. Sites which
  19587. allow users to run POV-Ray from remote locations must use
  19588. separate provisions in the section below.
  19589.  
  19590. The archives must all be easily available on the service and
  19591. should be grouped together in a similar on-line area.
  19592.  
  19593. It is strongly requested that sites remove prior versions of POV-
  19594. Ray to avoid user confusion and simplify or minimize our support
  19595. efforts.
  19596.  
  19597. The site may only charge standard usage rates for the downloading
  19598. of this software. A premium may not be charged for this package.
  19599. I.E. CompuServe or America On-Line may make these archives
  19600. available to their users, but they may only charge regular usage
  19601. rates for the time required to download.
  19602.  
  19603.  
  19604. 5.1.7     Online Or Remote Execution Of POV-Ray
  19605. Some internet sites have been set up so that remote users can
  19606. actually run POV-Ray software on the internet server. Other
  19607. companies sell CPU time for running POV-Ray software on
  19608. workstations or high-speed computers. Such use of POV-Ray
  19609. software is permitted under the following conditions.
  19610.  
  19611. Fees or charges, if any, for such services must be for connect
  19612. time, storage or processor usage ONLY. No premium charges may be
  19613. assessed for use of POV-Ray beyond that charged for use of other
  19614. software. Users must be clearly notified that they are being
  19615. charged for use of the computer and not for use of POV-Ray
  19616. software.
  19617.  
  19618. Users must be prominently informed that they are using POV-Ray
  19619. software, that such software is free, and where they can find
  19620. official POV-Ray software. Any attempt to obscure the fact that
  19621. the user is running POV-Ray is expressly prohibited.
  19622.  
  19623. All files normally available in a full package distribution,
  19624. especially a copy of this license and full documentation must be
  19625. available for download or readable online so that users of an
  19626. online executable have access to all of the material of a full
  19627. user package.
  19628.  
  19629. If the POV-Ray software has been modified in any way, it must
  19630. also follow the provisions for custom versions below.
  19631.  
  19632.  
  19633. 5.1.8     Permitted Modification And Custom Versions
  19634. Although the full source code for POV-Ray is distributed, there
  19635. are strict rules for the use of the source code. The source
  19636. distribution is provided to;  1) promote the porting of POV-Ray
  19637. to hardware and operating systems which the POV-Team cannot
  19638. support.  2) promote experimentation and development of new
  19639. features to the core code which might eventually be incorporated
  19640. into the official version.  3) provide insight into the inner
  19641. workings of the program for educational purposes.
  19642.  
  19643. These license provisions have been established to promote the
  19644. growth of POV-Ray and prevent difficulties for users and
  19645. developers alike. Please follow them carefully for the benefit of
  19646. all concerned when creating a custom version.
  19647.  
  19648. The user is granted the privilege to modify and compile the
  19649. source code for their own personal use in any fashion they see
  19650. fit. What you do with the software in your own home is your
  19651. business.
  19652.  
  19653. However severe restrictions are imposed if the user wishes to
  19654. distribute a modified version of the software, documentation or
  19655. other parts of the package (here after referred to as a "custom
  19656. version"). You must follow the provisions given below. This
  19657. includes any translation of the documentation into other
  19658. languages or other file formats.
  19659.  
  19660. A "custom version" is defined as a fully functional version of
  19661. POV-Ray with all existing features intact. ANY OTHER USE OF ANY
  19662. POV-Ray SOURCE CODE IS EXPRESSLY PROHIBITED. The POV-Team does
  19663. not license source code for any use outside POV-Ray. No portion
  19664. of the POV-Ray source code may be incorporated into another
  19665. program unless it is clearly a custom version of POV-Ray that
  19666. includes all of the basic functions of POV-Ray.
  19667.  
  19668. All executables, documentation, modified files and descriptions
  19669. of the same must clearly identify themselves as a modified and
  19670. unofficial version of POV-Ray. Any attempt to obscure the fact
  19671. that the user is running POV-Ray or to obscure that this is an
  19672. unofficial version expressly prohibited.
  19673.  
  19674. POV-Ray may not be linked into other software either at compile-
  19675. time using an object code linker nor at run-time as a DLL,
  19676. ActiveX, or other system. Such linkage can tend to blur the end-
  19677. user's perception of which program provides which functions and
  19678. thus qualifies as an attempt to obscure what is running.
  19679.  
  19680. To allow POV-Ray to communicate with outside programs, the
  19681. official versions of POV-Ray include several internal
  19682. communication "hooks" for it to call other tasks, often called an
  19683. Application Programming Interface, or API. For example: the
  19684. generic part of POV-Ray provides operating system shell-out API
  19685. commands. The Windows version has a GUI-extension API and the
  19686. ability to replace the text editor. Modification to these APIs or
  19687. other officially supported communication mechanisms to increase
  19688. functionality beyond that of the official version IS EXPRESSLY
  19689. PROHIBITED.
  19690.  
  19691.  
  19692. 5.1.9     Conditions For Distribution Of Custom Versions
  19693. If your re-compiled version meets all requirements for custom
  19694. versions listed above, the following conditions apply to its
  19695. distribution:
  19696.  
  19697. You must provide all POV-Ray support for all users who use your
  19698. custom version. You must provide information so that user may
  19699. contact you for support for your custom version. The POV-Ray Team
  19700. is not obligated to provide you or your users any technical
  19701. support.
  19702.  
  19703. Include contact information in the DISTRIBUTION_MESSAGE macros in
  19704. the source file OPTOUT.H and insure that the program prominently
  19705. displays this information. Display all copyright notices and
  19706. credit screens for the official version.
  19707.  
  19708. Custom versions may only be distributed as freeware. You must
  19709. make all of your modifications to POV-Ray freely and publicly
  19710. available with FULL SOURCE CODE to the modified portions of POV-
  19711. Ray and must freely distribute full source to any new parts of
  19712. the custom version. The goal is that users must be able to re-
  19713. compile the program themselves using readily available compilers
  19714. and run-time libraries and to be able to further improve the
  19715. program with their own modifications.
  19716.  
  19717. You must provide documentation for any and all modifications that
  19718. you have made to the program that you are distributing. Include
  19719. clear and obvious information on how to obtain the official POV-
  19720. Ray.
  19721.  
  19722. The user is encouraged to send enhancements and bug fixes to the
  19723. POV-Ray Team, but the team is in no way required to utilize these
  19724. enhancements or fixes. By sending material to the team, the
  19725. contributor asserts that he owns the materials or has the right
  19726. to distribute these materials. He authorizes the team to use the
  19727. materials any way they like. The contributor still retains rights
  19728. to the donated material, but by donating, grants unrestricted,
  19729. irrevocable usage and distribution rights to the POV- Team. The
  19730. team doesn't have to use the material, but if we do, you do not
  19731. acquire any rights related to POV-Ray. The team will give you
  19732. credit as the creator of new code if applicable.
  19733.  
  19734. Include a copy of this document (POVLEGAL.DOC).
  19735.  
  19736.  
  19737. 5.1.10    Conditions For Commercial Bundling
  19738. Vendors wishing to bundle POV-Ray with commercial software
  19739. (including shareware) or other distribution not already described
  19740. above must first obtain explicit permission from the POV-Team.
  19741. Such permission is rarely granted. The POV-Team will decide if
  19742. such distribution will be allowed on a case-by-case basis and may
  19743. impose certain restrictions as it sees fit. The minimum terms are
  19744. given below. Other conditions may be imposed.
  19745.  
  19746. The product must be an existing product that has proven itself as
  19747. commercially viable without POV-Ray included.    The inclusion of
  19748. POV-Ray should be promoted only as a free bonus and not as a
  19749. feature designed to encourage customers to purchase or upgrade
  19750. solely for the POV-Ray capability.    Purchasers of your product
  19751. must not be led to believe that they are paying for POV-Ray. Any
  19752. mention of the POV-Ray bundle on the box, in advertising or in
  19753. instruction manuals must be clearly marked with a disclaimer that
  19754. POV-Ray is free software and can be obtained for free or nominal
  19755. cost from various sources.    Include clear and obvious
  19756. information on how to obtain the official POV-Ray.    You must
  19757. provide all POV-Ray support for all users who acquired POV- Ray
  19758. through your product. The POV-Team is not obligated to provide
  19759. you or your customers any technical support.    Include a credit
  19760. page or pages in your documentation for POV-Ray.    If you modify
  19761. any portion POV-Ray for use with your hardware or software, you
  19762. must follow the custom version rules in addition to these rules.
  19763. Include contact and support information for your product.
  19764. Include a full user package as described above.
  19765.  
  19766.  
  19767. 5.1.11    POV-Team Endorsement Prohibitions
  19768. On rare occasions, the POV-Team endorses distributions in which
  19769. POV-Team members are compensated participants and which the POV-
  19770. Team has given approval.
  19771.  
  19772. Without specific approval, distributors (whether free or
  19773. commercial) must not claim or imply in any way that the POV-Team
  19774. officially endorses or supports the distributor or the product
  19775. (such as CD, book, or magazine) associated with the distribution.
  19776.  
  19777. You may not claim or imply that the POV-Team derives any benefit
  19778. from your distribution.
  19779.  
  19780. If you wish to emphasize that your distribution is legal, you may
  19781. use this language "This distribution of the official version of
  19782. POV-Ray is permitted under the terms of the General License in
  19783. the file POVLEGAL.DOC. The POV- Team does not endorse the
  19784. distributor or its products. The POV-Team receives no
  19785. compensation for this distribution."
  19786.  
  19787.  
  19788. 5.1.12    Retail Value Of This Software
  19789. Although POV-Ray is, when distributed within the terms of this
  19790. agreement, free of charge, the retail value (or price) of this
  19791. program is determined as US$20.00 per copy distributed or copied.
  19792. If the software is distributed or copied without authorization
  19793. you are legally liable to this debt to the copyright holder or
  19794. any other person or organization delegated by the copyright
  19795. holder for the collection of this debt, and you agree that you
  19796. are legally bound by the above and will pay this debt within 30
  19797. days of the event.
  19798.  
  19799. However, none of the above paragraph constitutes permission for
  19800. you to distribute this software outside of the terms of this
  19801. agreement. In particular, the conditions and debt mentioned above
  19802. (whether paid or unpaid) do not allow you to avoid statutory
  19803. damages or other legal penalties and does not constitute any
  19804. agreement that would allow you to avoid such other legal remedies
  19805. as are available to the copyright holder.
  19806.  
  19807. Put simply, POV-Ray is only free if you comply with our
  19808. distribution conditions; it is not free otherwise. The copyright
  19809. holder of this software chooses to give it away free under these
  19810. and only these conditions.
  19811.  
  19812. For the purpose of copyright regulations, the retail value of
  19813. this software is US$20.00 per copy.
  19814.  
  19815.  
  19816. 5.1.13    Other Provisions
  19817. The team permits and encourages the creation of programs,
  19818. including commercial packages, which import, export or translate
  19819. files in the POV-Ray Scene Description Language. There are no
  19820. restrictions on use of the language itself. We reserve the right
  19821. to add or remove or change any part of the language.
  19822.  
  19823. "POV-Ray", "Persistence of Vision", "POV-Team" and "POV-Help" are
  19824. trademarks of the POV-Team.
  19825.  
  19826. While we do not claim any restrictions on the letters "POV"
  19827. alone, we humbly request that you not use POV in the name of your
  19828. product. Such use tends to imply it is a product of the POV-Team.
  19829. Existing programs which used "POV" prior to the publication of
  19830. this document need not feel guilty for doing so provided that you
  19831. make it clear that the program is not the work of the team nor
  19832. endorsed by us.
  19833.  
  19834.  
  19835. 5.1.14    Revocation Of License
  19836. VIOLATION OF THIS LICENSE IS A VIOLATION OF COPYRIGHT LAWS. IT
  19837. WILL RESULT IN REVOCATION OF ALL DISTRIBUTION PRIVILEGES AND MAY
  19838. RESULT IN CIVIL OR CRIMINAL PENALTY.
  19839.  
  19840. Such violators who are prohibited from distribution will be
  19841. identified in this document.
  19842.  
  19843. In this regard, "PC Format", a magazine published by Future
  19844. Publishing, Ltd. in the United Kingdom, distributed incomplete
  19845. versions of POV-Ray 1.0 in violation the license which was effect
  19846. at the time. They later attempted to distribute POV-Ray 2.2
  19847. without prior permission of the POV- Team in violation the
  19848. license which was in effect at the time. There is evidence that
  19849. other Future Publishing companies have also violated our terms.
  19850. Therefore "PC Format", and any other magazine, book or CD-ROM
  19851. publication owned by Future Publishing is expressly prohibited
  19852. from any distribution of POV-Ray software until further notice.
  19853.  
  19854.  
  19855. 5.1.15    Disclaimer
  19856. This software is provided as is without any guarantees or
  19857. warranty. Although the authors have attempted to find and correct
  19858. any bugs in the package, they are not responsible for any damage
  19859. or losses of any kind caused by the use or misuse of the package.
  19860. The authors are under no obligation to provide service,
  19861. corrections, or upgrades to this package.
  19862.  
  19863.  
  19864. 5.1.16    Technical Support
  19865. We sincerely hope you have fun with our program. If you have any
  19866. problems with the program, the team would like to hear about
  19867. them. Also, if you have any comments, questions or enhancements,
  19868. please contact the POV-Ray Team on the CompuServe Information
  19869. Service in the GO POVRAY forum or check us out on the internet at
  19870. http://www.povray.org or ftp.povray.org. The USENET group
  19871. comp.graphics.rendering.raytracing is a great source of
  19872. information on POV-Ray and related topics.
  19873.  
  19874. License inquiries should be made via email and limited technical
  19875. support is available via email to:
  19876.  
  19877. Chris Young  POV-Ray Team Coordinator  CIS: 76702,1655  Internet
  19878. 76702.1655@compuserve.com
  19879.  
  19880. The following postal address is only for official license
  19881. business and only if email is impossible.
  19882.  
  19883. We do not provide technical support via regular mail, only email.
  19884. We don't care if you don't have a modem or online access. We will
  19885. not mail you disks with updated versions. Do not send money.
  19886.  
  19887. Chris Young; 3119 Cossell Drive; Indianapolis, IN 46224 U.S.A.
  19888.  
  19889. The other authors' contact information may be found in the
  19890. documentation.
  19891.  
  19892.  
  19893. 5.2  Authors
  19894. Following is a list in alphabetic order of all people who have
  19895. ever worked on the POV-Ray Team or who have made a note-worthy
  19896. contribution. If you want to contact or thank the authors read
  19897. the sections "Contacting the Authors" or use email addresses
  19898. below.
  19899.  
  19900.  
  19901.                  CURRENT POV-Team MEMBERS
  19902. NAME            PARTICIPATION            EMAIL
  19903. Dieter Bayer    Wrote sor, lathe,        104707.643@compuse
  19904.                 prism, media and many    rve.com
  19905.                 other features
  19906. Thomas Baier    New 3.1 team member,     thbaier@ibm.net
  19907.                 tester
  19908. Chris Cason     Windows version          
  19909.                 coordinator and other
  19910.                 contributions
  19911. Dale C. Brodin  Alpha & Beta tester,     74361.1764@compuse
  19912.                 forum support            rve.com
  19913.                                          brodin@execpc.com
  19914. Thorsten        Mac developer            ThorstenFroehlich@
  19915. Froehlich                                compuserve.com
  19916. Alan Kong       Alpha & Beta tester,     alkong@compuserve.
  19917.                 forum support            com
  19918. Lutz            Moray author, MS-Dos 24- lutz@stmuc.com
  19919. Kretzschmar     bit VGA, part of the
  19920.                 anti-aliasing code
  19921. Robert A.       Artist, 3.0 docs         71042.751@compuser
  19922. Mickelsen       contributor              ve.com
  19923.                                          ram@iu.net
  19924.                                          www.websharx.com/
  19925.                                          kahuna
  19926. Joel Newkirk    Primary Amiga developer  newkirk@snip.net
  19927. Nathan O'Brien  Artist, tester           no13@no13.net
  19928. Redaelli Paolo  Amiga developer          redaelli@inc.it
  19929. Anton Raves     Alpha & Beta tester,     100022.2603@compus
  19930.                 Mac contributor          erve.com
  19931. Eduard Schwan   Mac version              104706.3276@compus
  19932.                 coordinator, mosaic      erve.com
  19933.                 preview, docs            povraymac@compuser
  19934.                                          ve.com
  19935.                                          espsw@compuserve.c
  19936.                                          om
  19937.                                          http://ourworld.co
  19938.                                          mpuserve.com/homep
  19939.                                          ages/povraymac
  19940. Erkki           Alpha & Beta tester,     
  19941. Sondergaard     3.0 Scene files
  19942. Timothy Wegner  Fractal objects, PNG     71320.675@compuser
  19943.                 support                  ve.com
  19944.                                          twegner@phoenix.ne
  19945.                                          t
  19946. Chris Young     POV-Team coordinator,    76702.1655@compuse
  19947.                 parser code              rve.com
  19948.  
  19949.  
  19950.            PAST POV-Team MEMBERS and CONTRIBTORS
  19951. NAME            PARTICIPATION            EMAIL
  19952. Claire          Tutorials for the POV-   
  19953. Amundsen        Ray User Guide
  19954. Steve Anger     POV-Ray 2.0/3.0          70714.3113@compuse
  19955.                 developer                rve.com
  19956.                                          sanger@globalserve
  19957.                                          .net
  19958. Randy Antler    MS-Dos display code      
  19959.                 enhancements
  19960. John Baily      RLE targa code           
  19961. Eric Barish     Ground fog code          
  19962. Kendall         PMODE library support    
  19963. Bennett
  19964. Steve Bennett   GIF support              
  19965. David Buck      Original author of       
  19966.                 DKBTrace
  19967.                 POV-Ray 1.0 developer
  19968. Aaron Collins   Co-author of DKBTrace    
  19969.                 2.12
  19970.                 POV-Ray 1.0 developer
  19971. Chris Dailey    POV-Ray 3.0 developer    
  19972. Steve Demlow    POV-Ray 3.0 developer    
  19973. Andreas Dilger  Former Unix              adilger@enel.ucalg
  19974.                 coordinator, Linux       ary.ca
  19975.                 developer, PNG support   www-
  19976.                                          mddsp.enel.ucalgar
  19977.                                          y.ca/People/adilge
  19978.                                          r/
  19979. Joris van       Mac beta tester          
  19980. Drunen Littel
  19981. Alexander       POV-Ray 1.0/2.0/3.0      70323.2461@compuse
  19982. Enzmann         developer                rve.com
  19983.                                          xander@mitre.com
  19984. Dan Farmer      POV-Ray 1.0/2.0/3.0      
  19985.                 developer
  19986. Charles Fusner  Blob, lathe and prism    
  19987.                 tutorial tutorials for
  19988.                 the POV-Ray User Guide
  19989. David Harr      Mac balloon help and     
  19990.                 palette code
  19991. Jimmy Hoeks     Help file for Windows    
  19992.                 user interface
  19993. Terry Kanakis   Camera fix               
  19994. Kari Juharvi    Ground fog code          
  19995. Kivisalo
  19996. Charles         MS-Dos display code      
  19997. Marslett
  19998. Pascal          Fractal objects          
  19999. Massimino
  20000. Jim McElhiney   POV-Ray 3.0 developer    
  20001. Robert A.       Artist, 3.0 docs         71042.751@compuser
  20002. Mickelsen       contributor              ve.com
  20003.                                          ram@iu.net
  20004.                                          www.mickelsenstudi
  20005.                                          os.com
  20006. Mike Miller     Artist, scene files,     
  20007.                 stones.inc
  20008. Douglas Muir    Bump maps, height        
  20009.                 fields
  20010. Jim Nitchals    Mac version, scene       
  20011.                 files (Jim passed away
  20012.                 in June 1998 but his
  20013.                 contributions to POV-
  20014.                 Ray will not be
  20015.                 forgotten)
  20016. Paul Novak      Texture contributions    
  20017. Dave Park       Amiga support, AGA       
  20018.                 video code
  20019. David Payne     RLE targa code           
  20020. Bill Pulver     Time code                
  20021. Dan Richardson  3.0 Docs                 
  20022. Tim Rowley      PPM and Windows-         trowley@geom.umn.e
  20023.                 specific BMP image       du
  20024.                 format support
  20025. Robert Skinner  Noise functions          
  20026. Zsolt           Halo code which was      zsolt@cg.tuwien.ac
  20027. Szalavari       later turned into media  .at
  20028. Scott Taylor    Leopard and onion        
  20029.                 textures
  20030. Timothy Wegner  Fractal objects, PNG     71320.675@compuser
  20031.                 support                  ve.com
  20032.                                          twegner@phoenix.ne
  20033.                                          t
  20034. Drew Wells      POV-Ray 1.0 developer,   
  20035.                 POV-Ray 1.0 team
  20036.                 coordinator
  20037.  
  20038.  
  20039. 5.2.1     Contacting the Authors
  20040. The POV-Team is a collection of volunteer programmers, designers,
  20041. animators and artists meeting via electronic mail on CompuServe's
  20042. POVRAY forum (GO POVRAY). The POV-Team's goal is to create freely
  20043. distributable, high quality rendering and animation software
  20044. written in C that can be easily ported to many different
  20045. computers.
  20046.  
  20047. If you have any questions about POV-Ray, please contact
  20048.  
  20049.   Chris Young
  20050.   POV-Team Coordinator
  20051.   76702.1655@compuserve.com
  20052. We love to hear about how you're using and enjoying the program.
  20053. We also will do our best try to solve any problems you have with
  20054. POV-Ray and incorporate good suggestions into the program.
  20055.  
  20056. If you have a question regarding commercial use or distribution
  20057. of POV-Ray, or anything else particularly sticky, please contact
  20058. Chris Young, the development team coordinator. Otherwise, spread
  20059. the mail around. We all love to hear from you!
  20060.  
  20061. Please do not send large files to us through the e-mail without
  20062. asking first. Send a query before you send the file, thanks!
  20063.  
  20064.  
  20065. 5.3  What to do if you don't have POV-Ray
  20066. This documentation assumes you already have POV-Ray installed and
  20067. running however the POV-Team does distribute this file by itself
  20068. in various formats including online on the internet.  If you
  20069. don't have POV-Ray or aren't sure you have the official version
  20070. or the latest version, then the following sections will tell you
  20071. what to get and where to get it.
  20072.  
  20073.  
  20074. 5.3.1     Which Version of POV-Ray should you use?
  20075. POV-Ray can be used under MS-Dos, Windows 3.x, Windows for
  20076. Workgroups 3.11, Windows 95, Windows NT, Apple Macintosh 68k,
  20077. Power PC, Amiga, Linux, UNIX and other platforms.  The latest
  20078. versions of the necessary files are available over CompuServe,
  20079. Internet, and various CD distributions. See section "Where to
  20080. Find POV-Ray Files" for more info.  If your platform is not
  20081. supported and you are proficient in compiling source code
  20082. programs written in C then, see section "Compiling POV-Ray" for
  20083. more information.
  20084.  
  20085.  
  20086. 5.3.1.1   Microsoft Windows 95/98/NT
  20087. The Windows version runs under Windows 95, Windows 98, and
  20088. Windows NT4 also should run under OS/2 Warp.
  20089.  
  20090. Windows 3.1 and Windows for Workgroups are no longer supported
  20091. however the MS-Dos version will run as a dos application under
  20092. those operating systems.
  20093.  
  20094. Required hardware and software:
  20095.  
  20096.   Minimum - 486/100 with 16mb RAM and Windows 95.
  20097.   Disk space - 15 megabytes
  20098. Required POV-Ray files:
  20099.  
  20100.   User archive POVWIN3.EXE - a self-extracting archive
  20101.      containing the program, sample scenes, standard include
  20102.      files and documentation. This file may be split into smaller
  20103.      files for easier downloading. Check the directory of your
  20104.      download or ftp site to see if other files are needed.
  20105. Recommended:
  20106.  
  20107.   Pentium 200 or Pentium II with 32mb and Windows 95 or NT4.
  20108.   SVGA display preferably with high color or true color ability
  20109.      and drivers installed.  (Note: accelerated graphics hardware
  20110.      will not improve performance.)
  20111. Optional: The source code is not needed to use POV-Ray. It is
  20112. provided for the curious and adventurous.
  20113.  
  20114.   POVWIN_S.ZIP --- The C source code for POV-Ray for Windows.
  20115.      Contains generic parts and Windows specific parts. It does
  20116.      not include sample scenes, standard include files and
  20117.      documentation so you should also get the executable archive
  20118.      as well.  POV-Ray can only be compiled using C compilers
  20119.      that create 32-bit Windows applications. We support Watcom
  20120.      10.5a or higher, Borland 4.52/5.0 compilers.
  20121.  
  20122. 5.3.1.2   MS-Dos & Windows 3.x
  20123.  The MS-Dos version runs under MS-Dos or as a DOS application
  20124. under Windows 3.1 or Windows for Workgroups 3.11. Although it
  20125. also runs under Windows 95/98/NT4 and OS/2 Warp, users of those
  20126. systems should use the Windows version..
  20127.  
  20128. Required hardware and software:
  20129.  
  20130.   A 386 or better CPU and at least 8 meg of RAM.
  20131.   About 6 meg disk space to install and 2-10 meg or more beyond
  20132.      that for working space.
  20133.   A text editor capable of editing plain ASCII text files. The
  20134.      EDIT program that comes with MS-Dos will work for moderate
  20135.      size files.
  20136.   Graphic file viewer capable of viewing GIF and perhaps TGA and
  20137.      PNG formats.
  20138. Required POV-Ray files:
  20139.  
  20140.   POVMSDOS.EXE - a self-extracting archive containing the
  20141.      program, sample scenes, standard include files and
  20142.      documentation in plain ASCII text format. This file may be
  20143.      split into smaller files for easier downloading. Check the
  20144.      directory of your download or ftp site to see if other files
  20145.      are needed.
  20146. Recommended:
  20147.  
  20148.   Pentium 200 or Pentium II (faster the better) 32 meg or more
  20149.      RAM.  SVGA display preferably with VESA interface and high
  20150.      color or true color ability.    (Note: accelerated graphics
  20151.      hardware will not improve performance.)
  20152.  
  20153. Optional: The source code is not needed to use POV-Ray. It is
  20154. provided for the curious and adventurous.
  20155.  
  20156.   POVMSD_S.ZIP - The C source code for POV-Ray for MS-Dos.
  20157.      Contains generic parts and MS-Dos specific parts. It does
  20158.      not include sample scenes, standard include files and
  20159.      documentation so you should also get the executable archive
  20160.      as well. Requires a C compiler that can create 32-bit
  20161.      protected mode applications. We support Watcom 11, Borland
  20162.      4.52 with DOS Power Pack and DJGPP 2.
  20163.  
  20164. 5.3.1.3   Linux for Intel x86
  20165. Required hardware and software:
  20166.  
  20167.   A 386 or better CPU and at least 8 meg of RAM.
  20168.   About 6 meg disk space to install and 2-10 meg or more beyond
  20169.      that for working space.
  20170.   A text editor capable of editing plain ASCII text files.
  20171.   Graphic file viewer capable of viewing PPM, TGA or PNG
  20172.      formats.
  20173.   Any recent (1994 onwards) Linux kernel and support for ELF
  20174.      format binaries. POV-Ray for Linux is not in a.out-format.
  20175.      ELF libraries libc.so.5, libm.so.5 and one or both of
  20176.      libX11.so.6 or libvga.so.1.
  20177.   
  20178. Required POV-Ray files:
  20179.  
  20180.   POVLINUX.TGZ or POVLINUX.TAR.GZ - archive containing an
  20181.      official binary for each SVGALib and X-Windows modes. Also
  20182.      contains sample scenes, standard include files and
  20183.      documentation in plain ASCII text.
  20184. Recommended:
  20185.  
  20186.   Pentium 200 or Pentium II (faster the better) 32 meg or more
  20187.      RAM.  SVGA display preferably with VESA interface and high
  20188.      color or true color ability.  If you want display, you'll
  20189.      need either SVGALib or X-Windows.  (Note: accelerated
  20190.      graphics hardware will not improve performance.)
  20191. Optional: The source code is not needed to use POV-Ray. It is
  20192. provided for the curious and adventurous.
  20193.  
  20194.   POVUNI_S.TAR.GZ or POVUNI_S.TGZ - The C source code for POV-
  20195.      Ray for Linux. Contains generic parts and Linux specific
  20196.      parts. It does not include sample scenes, standard include
  20197.      files and documentation so you should also get the
  20198.      executable archive as well.  Requires the GNU C compiler and
  20199.      (optionally) the X include files and libraries.
  20200.  
  20201. 5.3.1.4   Apple Macintosh
  20202. The MacOS versions run under Apple's MacOS operating system
  20203. version 7.1 or newer, on any 68020/030/040-based Macintosh-
  20204. compatible computer (with or without a floating point
  20205. coprocessor) or any of the PowerPC Macintosh-compatible
  20206. computers.
  20207.  
  20208. Required hardware and software:
  20209.  
  20210.   A 68020 or better CPU without a floating point unit (LC or
  20211.      Performa or Centris series); at least 8 MB RAM or
  20212.   A 68020 or better CPU *with* a floating point unit (Mac II or
  20213.      Quadra series); at least 8 MB RAM or
  20214.   Any PowerPC Macintosh computer and at least 8 MB RAM.
  20215.   System 7.1 or newer and color QuickDraw (System 6 is no longer
  20216.      supported).
  20217.   Appearance Extension is also required now.  This comes
  20218.      standard in MacOS 8, but can be downloaded from Apple's web
  20219.      site <http://developer.apple.com/sdk/> and installed on any
  20220.      Mac running 7.1 or newer.
  20221.   Navigation Services is not required, but will enhance the
  20222.      open/save dialogs if it is present.  It is also a free
  20223.      extension available from Apple's web site, which can be used
  20224.      in 7.5.5 or newer.
  20225.   About 6 MB free disk space to install and an additional 2-10
  20226.      MB free space for your own creations (scenes and images).
  20227.   Graphic file viewer utility capable of viewing Mac PICT, GIF
  20228.      and perhaps TGA and PNG formats (the shareware
  20229.      GraphicConverter or GIFConverter applications are good.)
  20230. Required POV-Ray files:
  20231.  
  20232.   POVMACNF.SIT or POVMACNF.SIT.HQX - a Stuffit archive
  20233.      containing the non-FPU 68K Macintosh application, sample
  20234.      scenes, standard include files and documentation (slower
  20235.      version for Macs without an FPU) or
  20236.   POVMAC68.SIT or POVMAC68.SIT.HQX - a Stuffit archive
  20237.      containing the FPU 68K Macintosh application, sample scenes,
  20238.      standard include files and documentation (faster version for
  20239.      Macs WITH an FPU) or
  20240.   POVPMAC.SIT or POVPMAC.SIT.HQX - a Stuffit archive containing
  20241.      the native Power Macintosh application, sample scenes,
  20242.      standard include files and documentation.
  20243. Recommended:
  20244.  
  20245.   68030/33 or faster with FPU, or any Power Macintosh
  20246.   8 MB or more RAM for 68K Macintosh;
  20247.   16 MB or more for Power Macintosh systems.
  20248.   Color monitor preferred, 256 colors OK, but thousands or
  20249.      millions of colors is even better.
  20250. Optional: The source code is not needed to use POV-Ray. It is
  20251. provided for the curious and adventurous. POV-Ray can be compiled
  20252. using Apple's MPW 3.3, Metrowerks CodeWarrior Pro or Symantec 8.
  20253.  
  20254.   POVMACS.SIT or POVMACS.SIT.HQX - The full C source code for
  20255.      POV-Ray for Macintosh. Contains generic parts and Macintosh
  20256.      specific parts. It does not include sample scenes, standard
  20257.      include files and documentation so you should also get the
  20258.      executable archive as well.
  20259.   
  20260.  
  20261. 5.3.1.5   Amiga
  20262. The Amiga version comes in several flavors, 68000/68020 without
  20263. FPU, (not recommended, very slow) 68020/68030 with FPU, 68040,
  20264. and 68060. There's two way to use POV: Shell only and using the
  20265. provided GUI interface which requires MUI 3.8. All versions run
  20266. under OS3.x and up. Support exists for pensharing and window
  20267. display under OS3.x with 256 color palettes, plus CyberGraphics
  20268. and Picasso 96 24-bit display.
  20269.  
  20270. Required:
  20271.  
  20272.   At least 4 meg of RAM.
  20273.   At least 2 meg of hard disk space for the necessities, 5-20
  20274.      more recommended for workspace.
  20275.   An ASCII text editor, GUI configurable to launch the editor of
  20276.      your choice.
  20277.   Graphic file viewer - POV-Ray outputs to PNG, Targa (TGA), and
  20278.      PPM formats. POV-Ray Amiga can load any image format with
  20279.      Picture.Datatype V43 and the appropriate datatype.
  20280. Required POV-Ray files:
  20281.  
  20282.   POVAMIx0.LHA -- a LHA archive containing executable, sample
  20283.      scenes, standard include files, and documentation for the
  20284.      680x0 version of POV-Ray (i.e.: POVAMI60.LHA stands for
  20285.      68060 version); 68020 version needs FPU.
  20286. Recommended:
  20287.  
  20288.   8 meg or more of RAM.
  20289.   68030 & 68882 or higher processor.
  20290.   24bit display card (CyberGFX and Picasso 96 library supported)
  20291. Amiga PowerPC version of POV-Ray is now in beta testing. Watch
  20292. the CompuServe forum or ww.povray.org for further news.
  20293.  
  20294. Optional: The source code is not needed to use POV-Ray. It is
  20295. provided for the curious and adventurous.
  20296.  
  20297.   POVAMI_S.LHA --- The C source code for POV-Ray for Amiga.
  20298.      Contains generic parts and Amiga specific parts. It does not
  20299.      include sample scenes, standard include files, and
  20300.      documentation so you should also get the executable archive
  20301.      as well.
  20302.  
  20303. 5.3.1.6   SunOS
  20304. Required hardware and software:
  20305.  
  20306.   A Sun SPARC processor and at least 4 meg of RAM.
  20307.   About 6 meg disk space to install and 2-10 meg or more beyond
  20308.      that for working space.
  20309.   Graphic file viewer capable of viewing PPM, TGA or PNG
  20310.      formats.
  20311.   A text editor capable of editing plain ASCII text files.
  20312.   SunOS 4.1.3 or other operating system capable of running such
  20313.      a binary (Solaris or possibly Linux for Sparc).
  20314. Required POV-Ray files:
  20315.  
  20316.   POVSUNOS.TGZ or POVSUNOS.TAR.GZ - archive containing an
  20317.      official binary for each text-only and X-Windows modes. Also
  20318.      contains sample scenes, standard include files and
  20319.      documentation.
  20320. Recommended:
  20321.  
  20322.   8 meg or more RAM.
  20323.   If you want display, you'll need X-Windows or an X-Term.-
  20324.      preferably 24-bit TrueColor display ability, although the X
  20325.      display code is known to work with ANY combination of visual
  20326.      and color depth.
  20327.   Graphic file viewer capable of viewing PPM, TGA or PNG
  20328.      formats.
  20329. Optional: The source code is not needed to use POV-Ray. It is
  20330. provided for the curious and adventurous.
  20331.  
  20332.   POVUNI_S.TGZ or POVUNI_S.TAR.GZ - The C source code for POV-
  20333.      Ray for UNIX.  Contains generic parts and Unix/Linux
  20334.      specific parts. It does not include sample scenes, standard
  20335.      include files and documentation so you should also get the
  20336.      executable archive as well. You will need a C compiler and
  20337.      (optionally) the X include files and libraries and knowledge
  20338.      of how to use it. Although we provide source code for
  20339.      generic Unix systems, we do not provide technical support on
  20340.      how to compile the program.
  20341.  
  20342. 5.3.1.7   Generic Unix
  20343. Because Unix runs on a wide variety of hardware and CPUs, the POV-
  20344. Team cannot provide executable versions for every type of Unix.
  20345. We distribute generic Unix source code in portable ANSI C source
  20346. code.  You will need a C compiler and (optionally) the X include
  20347. files and libraries and knowledge of how to use it. Although we
  20348. provide source code for generic Unix systems, we do not provide
  20349. technical support on how to compile the program.
  20350.  
  20351. Required:
  20352.  
  20353.   POVUNI_S.TGZ or POVUNI_S.TAR.GZ - The C source code for POV-
  20354.      Ray for UNIX.  Contains generic parts and Unix/Linux
  20355.      specific parts. It does not include sample scenes, standard
  20356.      include files and documentation so you should also get an
  20357.      executable archive for another platform or get
  20358.   POVUNI_D.TGZ or POVUNI_D.TAR.GZ which contains the sample
  20359.      scenes, standard include files and documentation.
  20360.   A C compiler for your computer and KNOWLEDGE OF HOW TO USE IT.
  20361.   Graphic file viewer capable of viewing PPM, TGA or PNG
  20362.      formats.
  20363.   A text editor capable of editing plain ASCII text files.
  20364. Recommended:
  20365.  
  20366.   Math co-processor.
  20367.   8 meg or more RAM.
  20368. Optional:
  20369.  
  20370.   X Windows if you want to be able to display as you render.
  20371.   You will need the X-Windows include files as well. If you're
  20372.      not familiar with compiling programs for X-Windows you may
  20373.      need some help from someone who is knowledgeable at your
  20374.      installation because the X include files and libraries are
  20375.      not always in a standard place.
  20376.  
  20377. 5.3.1.8   All Versions
  20378. Each executable archive includes full documentation for POV-Ray
  20379. itself as well as specific instructions for using POV-Ray with
  20380. your type of platform. All versions of the program share the same
  20381. ray-tracing features like shapes, lighting and textures. In other
  20382. words, an MS-Dos-PC can create the same pictures as a Cray
  20383. supercomputer as long as it has enough memory. The user will want
  20384. to get the executable that best matches their computer hardware.
  20385.  
  20386. In addition to the files listed above, the POV-Team also
  20387. distributes the user documentation in two alternate forms.  Note
  20388. this is the same documentation distributed in other archives but
  20389. in a different format.  This may be especially useful for MS-Dos
  20390. or Unix users because their documentation is plain ASCII text
  20391. only.
  20392.  
  20393.   POVUSER.PDF - Tutorial and Reference documentation in Adobe
  20394.      Acrobat PDF format.  Requires Adobe Acrobat Reader available
  20395.      for Windows 3.x, Windows 95/98/NT, Mac and some Unix
  20396.      systems.  Go to
  20397.      http://www.adobe.com/prodindex/acrobat/readstep.html to get
  20398.      the reader for free.
  20399.   POVHTML.ZIP - Archive containing Tutorial and Reference
  20400.      documentation in html for viewing with any internet browser.
  20401.   POV31W97.ZIP - Archive containing Tutorial and Reference
  20402.      documentation in Microsoft Word 97 format.
  20403. See the section "Where to Find POV-Ray Files" for where to find
  20404. these files. You can contact those sources to find out what the
  20405. best version is for you and your computer.
  20406.  
  20407.  
  20408. 5.3.2     Where to Find POV-Ray Files
  20409. The latest versions of the POV-Ray software are available from
  20410. the following sources.
  20411.  
  20412.  
  20413. 5.3.2.1   POV-Ray Forum on CompuServe
  20414. The headquarters of POV-Ray are on CompuServe in the POVRAY
  20415. forum, that is managed by some of the team members. We meet there
  20416. to share information, useful programs and utilities and graphics
  20417. created by POV-Ray. Members of our CompuServe Forum also get
  20418. early access to beta versions and first hand support from POV-
  20419. Team members. Everyone is welcome to join in on the action on
  20420. CIS:POVRAY. Hope to see you there! You can get information on
  20421. joining CompuServe by calling (800)848-8990 or visit the
  20422. CompuServe home page http://www.compuserve.com. Direct CompuServe
  20423. access is also available in Japan, Europe and many other
  20424. countries.
  20425.  
  20426.  
  20427. 5.3.2.2   World Wide Website www.povray.org
  20428. The internet home of POV-Ray is reachable on the World Wide Web
  20429. via the address http://www.povray.org and via ftp as
  20430. ftp.povray.org. Please stop by often for the latest files,
  20431. utilities, news and images from the official POV-Ray internet
  20432. site.
  20433.  
  20434. The comp.graphics.rendering.raytracing newsgroup has many
  20435. competent POV-Ray users that are very willing to share their
  20436. knowledge. They generally ask that you first browse a few files
  20437. to see if someone has already answered the same question, and of
  20438. course, that you follow proper "netiquette". If you have any
  20439. doubts about the qualifications of the folks that frequent the
  20440. group, a few minutes spend at the Ray Tracing Competition pages
  20441. at www.povray.org will quickly convince you!
  20442.  
  20443. Also the POV-Team operates its own news server on the internet
  20444. with several news groups related to POV-Ray and other interesting
  20445. programs.  For more information about the server see
  20446. http://www.povray.org/groups.html.
  20447.  
  20448.  
  20449. 5.3.2.3   Books, Magazines and CD-ROMs
  20450. Unfortunately all English language books on POV-Ray are out of
  20451. print and there are no plans to reprint them.  However there is
  20452. now a POV-Ray 3.02 book and CD-ROM available in Japanese.  It
  20453. talks about the Windows and Mac versions of POV-Ray, and various
  20454. utilities.  The CD-ROM is dual format, Windows/Mac. It was
  20455. written in Japan by Hideki Komuro-san, and published by ASCII
  20456. Corp. in June 1998, ISBN 4-7561-1831-3.
  20457.  
  20458. Many popular computer magazines have been authorized to
  20459. distribute POV-Ray on cover CDs.  Note that such distributions of
  20460. the official version of POV-Ray is permitted under the terms of
  20461. the General License in the file POVLEGAL.DOC.  The POV-Team does
  20462. not endorse the distributor or its products.  The POV-Team
  20463. receives no compensation for this distribution.
  20464.  
  20465. The POV-Team does endorse some CD-ROMs containing POV-Ray which
  20466. are prepared by team members.  A portion of the proceeds from
  20467. these CDs support our internet sites and other team activities.
  20468. You can always find the latest information on what is available
  20469. at our web site www.povray.org.
  20470.  
  20471.  
  20472. 5.4  Compiling POV-Ray
  20473. The following sections will help you to compile the portable C
  20474. source code into a working executable version of POV-Ray. They
  20475. are only for those people who want to compile a custom version of
  20476. POV-Ray or to port it to an unsupported platform or compiler.
  20477.  
  20478. The first question you should ask yourself before proceeding is
  20479. "Do I really need to compile POV-Ray at all?" Official POV-Team
  20480. executable versions are available for MS-Dos, Windows 95/98/NT,
  20481. Mac 68k, Mac Power PC, Amiga, Linux for Intel x86, and SunOS.
  20482. Other unofficial compiles may soon be available for other
  20483. platforms. If you do not intend to add any custom or experimental
  20484. features to the program and if an executable already exists for
  20485. your platform then you need not compile this program yourself.
  20486.  
  20487. If you do want to proceed you should be aware that you are very
  20488. nearly on your own. The following sections and other related
  20489. compiling documentation assume you know what you are doing. It
  20490. assumes you have an adequate C compiler installed and working. It
  20491. assumes you know how to compile and link large, multi-part
  20492. programs using a "make" utility or an IDE project file if your
  20493. compiler supports them. Because makefiles and project files often
  20494. specify drive, directory or path information, we cannot promise
  20495. our makefiles or projects will work on your system. We assume you
  20496. know how to make changes to makefiles and projects to specify
  20497. where your system libraries and other necessary files are
  20498. located.
  20499.  
  20500. In general you should not expect any technical support from the
  20501. POV-Team on how to compile the program. Everything is provided
  20502. here as is.  All we can say with any certainty is that we were
  20503. able to compile it on our systems. If it doesn't work for you we
  20504. probably cannot tell you why.
  20505.  
  20506. There is no technical documentation for the source code itself
  20507. except for the comments in the source files. We try our best to
  20508. write clear, well- commented code but some sections are barely
  20509. commented at all and some comments may be out dated. We do not
  20510. provide any technical support to help you to add features. We do
  20511. not explain how a particular feature works. In some instances,
  20512. the person who wrote a part of the program is no longer active in
  20513. the Team and we don't know exactly how it works.
  20514.  
  20515. When making any custom version of POV-Ray or any unofficial
  20516. compile, please make sure you read and follow all provisions of
  20517. our license in POVLEGAL.DOC.  In general you can modify and use
  20518. POV-Ray on your own however you want but if you distribute your
  20519. unofficial version you must follow our rules. You may not under
  20520. any circumstances use portions of POV-Ray source code in other
  20521. programs.
  20522.  
  20523.  
  20524. 5.4.1     Directory Structure
  20525. POV-Ray source code is distributed in archives with files
  20526. arranged in a particular hierarchy of directories or folders.
  20527. When extracting the archives you should do so in a way that keeps
  20528. the directory structure intact. In general we suggest you create
  20529. a directory called povray3 or povray31 and extract the files from
  20530. there. The extraction will create a directory called source with
  20531. many files and sub-directories.
  20532.  
  20533. In general, there are separate archives for each hardware
  20534. platform and operating system but each of these archives may
  20535. support more than one compiler. For example here is the directory
  20536. structure for the MS-Dos archive.  Other platforms use similar
  20537. structures.
  20538.  
  20539.   SOURCE
  20540.   SOURCE\LPNG101
  20541.   SOURCE\ZLIB
  20542.   SOURCE\MSDOS
  20543.   SOURCE\MSDOS\PMODE
  20544.   SOURCE\MSDOS\BORLAND
  20545.   SOURCE\MSDOS\DJGPP
  20546.   SOURCE\MSDOS\WATCOM
  20547. The source directory contains source files for the generic parts
  20548. of POV-Ray that are the same on all platforms. The source\lpng101
  20549. contains files for compiling a library of routines used in
  20550. reading and writing PNG (Portable Network Graphics) image files.
  20551. The source\zlib contains files for compiling a library of
  20552. routines used by libpng to compress and uncompress data streams.
  20553. All of these files are used by all platforms and compilers.  They
  20554. are in every version of the source archives.
  20555.  
  20556. The source\msdos directory contains all source files for the MS-
  20557. Dos version common to all supported MS-Dos compilers. The pmode
  20558. sub-directory contains source files for pmode.lib which is
  20559. required by all MS-Dos versions. The borland, djgpp, and watcom
  20560. sub-directories contain source, makefiles and project files for C
  20561. compilers by Borland, DJGPP and Watcom.
  20562.  
  20563. The source\msdos directory is only in the MS-Dos archive.
  20564. Similarly the Windows archive contains a source\windows
  20565. directory. The Unix archive contains source/unix etc.
  20566.  
  20567. The source\msdos directory contains a file cmpl_msd.doc which
  20568. contains compiling information specific to the MS-Dos version.
  20569. Other platform specific directories contain similar cmpl_xxx.doc
  20570. files and the compiler specific sub-directories also contain
  20571. compiler specific cmpl_xxx.doc files.  Be sure to read all
  20572. pertinent cmpl_xxx.doc files for your platform and compiler.
  20573.  
  20574.  
  20575. 5.4.2     Configuring POV-Ray Source
  20576. Every platform has a header file config.h that is generally in
  20577. the platform specific directory but may be in the compiler
  20578. specific directory. Some platforms have multiple versions of this
  20579. file and you may need to copy or rename it as config.h. This file
  20580. is included in every module of POV-Ray. It contains any
  20581. prototypes, macros or other definitions that may be needed in the
  20582. generic parts of POV-Ray but must be customized for a particular
  20583. platform or compiler.
  20584.  
  20585. For example different operating systems use different characters
  20586. as a separator between directories and file names. MS-Dos uses
  20587. back slash, Unix a front slash or Mac a colon. The config.h file
  20588. for MS-Dos and Windows contains the following:
  20589.  
  20590.   #define FILENAME_SEPARATOR '\'
  20591.  
  20592. which tells the generic part of POV-Ray to use a back slash.
  20593.  
  20594. Every customization that the generic part of the code needs has a
  20595. default setting in the file source\frame.h which is also included
  20596. in every module after config.h. The frame.h header contains many
  20597. groups of defines such as this:
  20598.  
  20599.   #ifndef FILENAME_SEPARATOR
  20600.   #define FILENAME_SEPARATOR '/'
  20601.   #endif
  20602. which basically says "If we didn't define this previously in
  20603. config.h then here's a default value". See frame.h to see what
  20604. other values you might wish to configure.
  20605.  
  20606. If any definitions are used to specify platform specific
  20607. functions you should also include a prototype for that function.
  20608. The file source\msdos\config.h, for example, not only contains
  20609. the macro:
  20610.  
  20611.   #define POV_DISPLAY_INIT(w,h) MSDOS_Display_Init ((w), (h));
  20612. to define the name of the graphics display initialization
  20613. function, it contains the prototype:
  20614.  
  20615.   void MSDOS_Display_Init (int w, int h);
  20616. If you plan to port POV-Ray to an unsupported platform you should
  20617. probably start with the simplest, non-display generic Unix
  20618. version. Then add new custom pieces via the config.h file.
  20619.  
  20620.  
  20621. 5.4.3     Conclusion
  20622. We understand that the above sections are only the most trivial
  20623. first steps but half the fun of working on POV-Ray source is
  20624. digging in and figuring it out on your own. That's how the POV-
  20625. Team members got started. We've tried to make the code as clear
  20626. as we can.
  20627.  
  20628. Be sure to read the cmpl_xxx.doc files in your platform specific
  20629. and compiler specific directories for some more minor help if you
  20630. are working on a supported platform or compiler.
  20631.  
  20632. Good luck!
  20633.  
  20634.  
  20635. 5.5  Suggested Reading
  20636. Beside the POV-Ray material mentioned in "Books, Magazines and CD-
  20637. ROMs" there are several good books or periodicals that you should
  20638. be able to locate in your local computer book store or your local
  20639. university library.
  20640.  
  20641.   "An Introduction to Ray tracing"  Andrew S. Glassner (editor)
  20642. ISBN 0-12-286160-4;  Academic Press 1989
  20643.  
  20644.   "3D Artist" Newsletter,  "The Only Newsletter about Affordable
  20645. PC 3D Tools and Techniques")  Publisher: Bill Allen;  P.O. Box
  20646. 4787; Santa Fe, NM 87502-4787;  (505) 982-3532
  20647.  
  20648.   "Image Synthesis:  Theory and Practice" Nadia Magnenat-Thalman
  20649. and Daniel Thalmann; Springer-Verlag; 1987
  20650.  
  20651.   "The RenderMan Companion" Steve Upstill; Addison Wesley; 1989
  20652.  
  20653.   "Graphics Gems" Andrew S. Glassner (editor); Academic Press;
  20654. 1990
  20655.  
  20656.   "Fundamentals of Interactive Computer Graphics"  J. D. Foley
  20657. and A. Van Dam;  ISBN 0-201-14468-9; Addison-Wesley 1983
  20658.  
  20659.   "Computer Graphics:  Principles and Practice (2nd Ed.)"  J. D.
  20660. Foley, A. van Dam, J. F. Hughes;  ISBN 0-201-12110-7;  Addison-
  20661. Wesley, 1990
  20662.  
  20663.   "Computers, Pattern, Chaos, and Beauty" Clifford Pickover;  St.
  20664. Martin's Press; "SIGGRAPH Conference Proceedings";   Association
  20665. for Computing Machinery Special Interest Group on Computer
  20666. Graphics
  20667.  
  20668.   "IEEE Computer Graphics and Applications";  The Computer
  20669. Society; 10662, Los Vaqueros Circle; Los Alamitos, CA 90720
  20670.  
  20671.   "The CRC Handbook of Mathematical Curves and Surfaces"  David
  20672. von Seggern; CRC Press; 1990
  20673.  
  20674.   "The CRC Handbook of Standard Mathematical Tables"  CRC Press
  20675.  
  20676.